Part Number Hot Search : 
B2205X 6403DE CXOMKHG ACM4004D CB07108 3TRG1 DLQ5256B 85HFR10M
Product Description
Full Text Search
 

To Download S9S12G128F0MLH Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  s12 microcontrollers freescale.com mc9s12g family reference manual and data sheet mc9s12grmv1 rev.1.23 february 1, 2013
mc9s12g family reference manual, rev.1.23 freescale semiconductor 2 to provide the most up-to-date information, the revision of our documents on the world wide web will be the most current. your printed copy may be an earlier revision. to verify you have the latest information available, refer to: freescale.com/ a full list of family members and options is included in the appendices.
mc9s12g family reference manual, rev.1.23 freescale semiconductor 3 the following revision history table summarizes changes contained in this document. revision history date revision level description sep, 2012 1.14 updated appendix a, ?lectrical characteristics (reason: updated electricals) sep, 2012 1.15 updated appendix a, ?lectrical characteristics (reason: updated electricals) sep, 2012 1.16 updated chapter 1, ?evice overview mc9s12g-family (reason: corrected pinout diagram) updated appendix a, ?lectrical characteristics (reason: updated electricals) nov, 2012 1.17 updated appendix a, ?lectrical characteristics (reason: updated electricals) nov, 2012 1.18 added chapter 12, ?nalog-to-digital converter (adc12b8cv2) added chapter 14, ?nalog-to-digital converter (adc12b12cv2) updated chapter 11, ?nalog-to-digital converter (adc10b8cv2) (reason: spec update) updated chapter 13, ?nalog-to-digital converter (adc10b12cv2) (reason: spec update) updated chapter 15, ?nalog-to-digital converter (adc10b16cv2) (reason: spec update) updated chapter 16, ?nalog-to-digital converter (adc12b16cv2) (reason: spec update) nov, 2012 1.19 corrected order of chapters jan, 2013 1.20 updated appendix a, ?lectrical characteristics (reason: added aec grade 0 spec) updated appendix c, ?rdering and shipping information (reason: added temperature option w) jan, 2013 1.21 separated description of 8-channel timer updated appendix a, ?lectrical characteristics (reason: updated electricals) jan, 2012 1.22 updated chapter 1, ?evice overview mc9s12g-family (reason: added kgd option for the s12ga192 and the s12ga240) updated appendix a, ?lectrical characteristics (reason: updated electricals) up[dated appendix c, ?rdering and shipping information (reason: added kgd information) added appendix d, ?ackage and die information (reason: added kgd information) feb, 2012 1.23 updated appendix c, ?rdering and shipping information (reason: removed kgd information) added appendix d, ?ackage and die information (reason: updated kgd information)
mc9s12g family reference manual, rev.1.23 4 freescale semiconductor this document contains information for all constituent modules, with the exception of the cpu. for cpu information please refer to cpu12-1 in the cpu12 & cpu12x reference manual
mc9s12g family reference manual, rev.1.23 freescale semiconductor 5
mc9s12g family reference manual, rev.1.23 6 freescale semiconductor
mc9s12g family reference manual, rev.1.23 freescale semiconductor 7
mc9s12g family reference manual, rev.1.23 8 freescale semiconductor
mc9s12g family reference manual, rev.1.23 freescale semiconductor 9
mc9s12g family reference manual, rev.1.23 10 freescale semiconductor
mc9s12g family reference manual, rev.1.23 freescale semiconductor 11
mc9s12g family reference manual, rev.1.23 12 freescale semiconductor
mc9s12g family reference manual, rev.1.23 freescale semiconductor 13
mc9s12g family reference manual, rev.1.23 14 freescale semiconductor
mc9s12g family reference manual, rev.1.23 freescale semiconductor 15 chapter 1 device overview mc9s12g-family . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .39 chapter 2 port integration module (s12gpimv1) . . . . . . . . . . . . . . . . . . . . . . . . . . .157 chapter 3 5v analog comparator (acmpv1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .257 chapter 4 reference voltage attenuator (rvav1) . . . . . . . . . . . . . . . . . . . . . . . . . .263 chapter 5 s12g memory map controller (s12gmmcv1) . . . . . . . . . . . . . . . . . . . . .267 chapter 6 interrupt module (s12sintv1). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .281 chapter 7 background debug module (s12sbdmv1) . . . . . . . . . . . . . . . . . . . . . . .289 chapter 8 s12s debug module (s12sdbgv2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . .313 chapter 9 security (s12xs9secv2). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .355 chapter 10 s12 clock, reset and power management unit (s12cpmu) . . . . . . . . .361 chapter 11 analog-to-digital converter (adc10b8cv2) . . . . . . . . . . . . . . . . . . . . . .419 chapter 12 analog-to-digital converter (adc12b8cv2) . . . . . . . . . . . . . . . . . . . . . .443 chapter 13 analog-to-digital converter (adc10b12cv2) . . . . . . . . . . . . . . . . . . . . .469 chapter 14 analog-to-digital converter (adc12b12cv2) . . . . . . . . . . . . . . . . . . . . .495 chapter 15 analog-to-digital converter (adc10b16cv2) . . . . . . . . . . . . . . . . . . . . .521 chapter 16 analog-to-digital converter (adc12b16cv2) . . . . . . . . . . . . . . . . . . . . .547 chapter 17 digital analog converter (dac_8b5v) . . . . . . . . . . . . . . . . . . . . . . . . . . .573 chapter 18 freescale? scalable controller area network (s12mscanv3) . . . . . .585 chapter 19 pulse-width modulator (s12pwm8b8cv2) . . . . . . . . . . . . . . . . . . . . . . .637 chapter 20 serial communication interface (s12sciv5) . . . . . . . . . . . . . . . . . . . . . .667 chapter 21 serial peripheral interface (s12spiv5) . . . . . . . . . . . . . . . . . . . . . . . . . . .705 chapter 22 timer module (tim16b6cv3). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .733 chapter 23 timer module (tim16b8cv3). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .751 chapter 24 16 kbyte flash module (s12ftmrg16k1v1) . . . . . . . . . . . . . . . . . . . . .779 chapter 25 32 kbyte flash module (s12ftmrg32k1v1) . . . . . . . . . . . . . . . . . . . . .827 chapter 26 48 kbyte flash module (s12ftmrg48k1v1) . . . . . . . . . . . . . . . . . . . . .879 chapter 27 64 kbyte flash module (s12ftmrg64k1v1) . . . . . . . . . . . . . . . . . . . . .931 chapter 28 96 kbyte flash module (s12ftmrg96k1v1) . . . . . . . . . . . . . . . . . . . . .983 chapter 29 128 kbyte flash module (s12ftmrg128k1v1) . . . . . . . . . . . . . . . . . .1035 chapter 30 192 kbyte flash module (s12ftmrg192k2v1) . . . . . . . . . . . . . . . . . .1087 chapter 31 240 kbyte flash module (s12ftmrg240k2v1) . . . . . . . . . . . . . . . . . .1139
mc9s12g family reference manual, rev.1.23 16 freescale semiconductor appendix a electrical characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1191 appendix b detailed register address map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1249 appendix c ordering and shipping information . . . . . . . . . . . . . . . . . . . . . . . . . . . .1269 appendix d package and die information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1271
mc9s12g family reference manual, rev.1.23 freescale semiconductor 19 chapter 1 device overview mc9s12g-family 1.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 1.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 1.2.1 mc9s12g-family comparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 1.2.2 chip-level features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .42 1.3 module features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 1.3.1 s12 16-bit central processor unit (cpu) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 1.3.2 on-chip flash with ecc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 1.3.3 on-chip sram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .43 1.3.4 port integration module (pim) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 1.3.5 main external oscillator (xosclcp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 1.3.6 internal rc oscillator (irc) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 1.3.7 internal phase-locked loop (ipll) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 1.3.8 system integrity support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 5 1.3.9 timer (tim) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 1.3.10 pulse width modulation module (pwm) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 1.3.11 controller area network module (mscan) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 1.3.12 serial communication interface module (sci) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 1.3.13 serial peripheral interface module (spi) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 1.3.14 analog-to-digital converter module (adc) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 1.3.15 reference voltage attenuator (rva) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 1.3.16 digital-to-analog converter module (dac) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 1.3.17 analog comparator (acmp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 1.3.18 on-chip voltage regulator (vreg) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 1.3.19 background debug (bdm) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 1.3.20 debugger (dbg) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 1.4 key performance parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 1.5 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 1.6 family memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 1.6.1 part id assignments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .54 1.7 signal description and device pinouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 1.7.1 pin assignment overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 1.7.2 detailed signal descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 1.7.3 power supply pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .60 1.8 device pinouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 1.8.1 s12gn16 and s12gn32 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 1.8.2 s12gna16 and s12gna32 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 1.8.3 s12gn48 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 1.8.4 s12g48 and s12g64 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 1 1.8.5 s12ga48 and s12ga64 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 1.8.6 s12g96 and s12g128 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 1.8.7 s12ga96 and s12ga128 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 1.8.8 s12g192 and s12g240 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 1.8.9 s12ga192 and s12ga240 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
mc9s12g family reference manual, rev.1.23 20 freescale semiconductor 1.9 system clock description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 1.10 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 1.10.1 chip con?uration summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 1.10.2 low power operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 9 1.11 security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 1.12 resets and interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 1.12.1 resets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 1.12.2 interrupt vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 1.12.3 effects of reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 1.13 cop con?uration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 1.14 autonomous clock (aclk) con?uration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 1.15 adc external trigger input connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 53 1.16 adc special conversion channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 1.17 adc result reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 1.18 adc vrh/vrl signal connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 4 1.19 bdm clock source connectivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 chapter 2 port integration module (s12gpimv1) 2.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 2.1.1 glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 2.1.2 overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158 2.1.3 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158 2.1.4 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 2.2 pim routing - external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 9 2.2.1 package code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 2.2.2 prioritization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 2.2.3 signals and priorities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 2.3 pim routing - functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 2.3.1 pin bkgd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 2.3.2 pins pa7-0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 2.3.3 pins pb7-0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 2.3.4 pins pc7-0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 2.3.5 pins pd7-0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 2.3.6 pins pe1-0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 2.3.7 pins pt7-0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 2.3.8 pins ps7-0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 2.3.9 pins pm3-0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 2.3.10 pins pp7-0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 2.3.11 pins pj7-0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 2.3.12 pins ad15-0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 2.4 pim ports - memory map and register de?ition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186 2.4.1 memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186 2.4.2 register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189 2.4.3 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
mc9s12g family reference manual, rev.1.23 freescale semiconductor 21 2.5 pim ports - functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249 2.5.1 general . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249 2.5.2 registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249 2.5.3 pin con?uration summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251 2.5.4 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252 2.6 initialization/application information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254 2.6.1 initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254 2.6.2 port data and data direction register writes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254 2.6.3 enabling irq edge-sensitive mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254 2.6.4 adc external triggers etrig3-0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254 2.6.5 emulation of smaller packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255 chapter 3 5v analog comparator (acmpv1) 3.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257 3.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257 3.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257 3.4 external signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258 3.5 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258 3.6 memory map and register de?ition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 59 3.6.1 register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259 3.6.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259 3.7 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261 chapter 4 reference voltage attenuator (rvav1) 4.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263 4.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263 4.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263 4.4 external signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264 4.5 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264 4.6 memory map and register de?ition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 65 4.6.1 register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265 4.6.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265 4.7 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266 chapter 5 s12g memory map controller (s12gmmcv1) 5.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267 5.1.1 glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267 5.1.2 overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267 5.1.3 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268 5.1.4 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 68 5.1.5 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
mc9s12g family reference manual, rev.1.23 22 freescale semiconductor 5.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269 5.3 memory map and registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269 5.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269 5.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270 5.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274 5.4.1 mcu operating modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274 5.4.2 memory map scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274 5.4.3 unimplemented and reserved address ranges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278 5.4.4 prioritization of memory accesses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279 5.4.5 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279 chapter 6 interrupt module (s12sintv1) 6.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281 6.1.1 glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281 6.1.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281 6.1.3 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 82 6.1.4 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282 6.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283 6.3 memory map and register de?ition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 83 6.3.1 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283 6.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284 6.4.1 s12s exception requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284 6.4.2 interrupt prioritization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284 6.4.3 reset exception requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285 6.4.4 exception priority . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285 6.5 initialization/application information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286 6.5.1 initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286 6.5.2 interrupt nesting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286 6.5.3 wake up from stop or wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286 chapter 7 background debug module (s12sbdmv1) 7.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289 7.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289 7.1.2 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 90 7.1.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291 7.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291 7.3 memory map and register de?ition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 91 7.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291 7.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292 7.3.3 family id assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296 7.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296 7.4.1 security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
mc9s12g family reference manual, rev.1.23 freescale semiconductor 23 7.4.2 enabling and activating bdm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296 7.4.3 bdm hardware commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297 7.4.4 standard bdm firmware commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298 7.4.5 bdm command structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299 7.4.6 bdm serial interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 01 7.4.7 serial interface hardware handshake protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304 7.4.8 hardware handshake abort procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306 7.4.9 sync ?request timed reference pulse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309 7.4.10 instruction tracing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309 7.4.11 serial communication time out . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310 chapter 8 s12s debug module (s12sdbgv2) 8.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313 8.1.1 glossary of terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313 8.1.2 overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314 8.1.3 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314 8.1.4 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 15 8.1.5 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315 8.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316 8.3 memory map and registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316 8.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316 8.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317 8.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332 8.4.1 s12sdbg operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333 8.4.2 comparator modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 33 8.4.3 match modes (forced or tagged) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337 8.4.4 state sequence control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 8 8.4.5 trace buffer operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 9 8.4.6 tagging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346 8.4.7 breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346 8.5 application information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348 8.5.1 state machine scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 8 8.5.2 scenario 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348 8.5.3 scenario 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349 8.5.4 scenario 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349 8.5.5 scenario 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349 8.5.6 scenario 5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351 8.5.7 scenario 6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351 8.5.8 scenario 7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351 8.5.9 scenario 8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352 8.5.10 scenario 9 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352 8.5.11 scenario 10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
mc9s12g family reference manual, rev.1.23 24 freescale semiconductor chapter 9 security (s12xs9secv2) 9.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355 9.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355 9.1.2 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 55 9.1.3 securing the microcontroller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356 9.1.4 operation of the secured microcontroller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357 9.1.5 unsecuring the microcontroller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358 9.1.6 reprogramming the security bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358 9.1.7 complete memory erase (special modes) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359 chapter 10 s12 clock, reset and power management unit (s12cpmu) 10.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361 10.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361 10.1.2 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364 10.1.3 s12cpmu block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367 10.2 signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369 10.2.1 reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369 10.2.2 extal and xtal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 9 10.2.3 vddr ?regulator power input pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369 10.2.4 vss ?ground pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 69 10.2.5 vdda, vssa ?regulator reference supply pins . . . . . . . . . . . . . . . . . . . . . . . . . . . 369 10.2.6 vddx, vssx?pad supply pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369 10.2.7 vdd ?internal regulator output supply (core logic) . . . . . . . . . . . . . . . . . . . . . . . 370 10.2.8 vddf ?internal regulator output supply (nvm logic) . . . . . . . . . . . . . . . . . . . . . 370 10.2.9 api_extclk api external clock output pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370 10.3 memory map and registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371 10.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371 10.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373 10.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405 10.4.1 phase locked loop with internal filter (pll) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405 10.4.2 startup from reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407 10.4.3 stop mode using pllclk as bus clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407 10.4.4 full stop mode using oscillator clock as bus clock . . . . . . . . . . . . . . . . . . . . . . . . . . 408 10.4.5 external oscillator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409 10.4.6 system clock con?urations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410 10.5 resets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411 10.5.1 general . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411 10.5.2 description of reset operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411 10.5.3 power-on reset (por) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414 10.5.4 low-voltage reset (lvr) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414 10.6 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414 10.6.1 description of interrupt operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414
mc9s12g family reference manual, rev.1.23 freescale semiconductor 25 10.7 initialization/application information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416 10.7.1 general initialization information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416 10.7.2 application information for cop and api usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416 chapter 11 analog-to-digital converter (adc10b8cv2) 11.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419 11.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420 11.1.2 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 421 11.1.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 422 11.2 signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423 11.2.1 detailed signal descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423 11.3 memory map and register de?ition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423 11.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423 11.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425 11.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440 11.4.1 analog sub-block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440 11.4.2 digital sub-block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440 11.5 resets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442 11.6 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442 chapter 12 analog-to-digital converter (adc12b8cv2) 12.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443 12.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444 12.1.2 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445 12.1.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446 12.2 signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447 12.2.1 detailed signal descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447 12.3 memory map and register de?ition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447 12.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447 12.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449 12.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 465 12.4.1 analog sub-block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 465 12.4.2 digital sub-block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 465 12.5 resets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467 12.6 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467 chapter 13 analog-to-digital converter (adc10b12cv2) 13.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 470 13.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 470 13.1.2 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471 13.1.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 472
mc9s12g family reference manual, rev.1.23 26 freescale semiconductor 13.2 signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473 13.2.1 detailed signal descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473 13.3 memory map and register de?ition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473 13.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473 13.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476 13.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491 13.4.1 analog sub-block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491 13.4.2 digital sub-block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491 13.5 resets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 493 13.6 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 493 chapter 14 analog-to-digital converter (adc12b12cv2) 14.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 496 14.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 496 14.1.2 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 497 14.1.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 498 14.2 signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 499 14.2.1 detailed signal descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 499 14.3 memory map and register de?ition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 499 14.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 499 14.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 502 14.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 518 14.4.1 analog sub-block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 518 14.4.2 digital sub-block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 518 14.5 resets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 520 14.6 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 520 chapter 15 analog-to-digital converter (adc10b16cv2) 15.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 522 15.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 522 15.1.2 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523 15.1.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 524 15.2 signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 525 15.2.1 detailed signal descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 525 15.3 memory map and register de?ition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 525 15.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 525 15.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 528 15.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 543 15.4.1 analog sub-block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 543 15.4.2 digital sub-block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 543 15.5 resets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 545 15.6 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 545
mc9s12g family reference manual, rev.1.23 freescale semiconductor 27 chapter 16 analog-to-digital converter (adc12b16cv2) 16.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 548 16.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 548 16.1.2 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 549 16.1.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 550 16.2 signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 551 16.2.1 detailed signal descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 551 16.3 memory map and register de?ition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 551 16.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 551 16.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 554 16.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 570 16.4.1 analog sub-block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 570 16.4.2 digital sub-block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 570 16.5 resets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 572 16.6 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 572 chapter 17 digital analog converter (dac_8b5v) 17.1 revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 573 17.2 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 574 17.2.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 574 17.2.2 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 574 17.2.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 575 17.3 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 575 17.3.1 dacu output pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 575 17.3.2 amp output pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 575 17.3.3 ampp input pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 575 17.3.4 ampm input pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 576 17.4 memory map and register de?ition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 576 17.4.1 register summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 576 17.4.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 576 17.5 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 578 17.5.1 functional overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 578 17.5.2 mode ?ff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 579 17.5.3 mode ?perational ampli?r . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 579 17.5.4 mode ?nbuffered dac . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 580 17.5.5 mode ?nbuffered dac with operational ampli?r . . . . . . . . . . . . . . . . . . . . . . . . . 580 17.5.6 mode ?uffered dac . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 580 17.5.7 analog output voltage calculation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 580 chapter 18 freescale? scalable controller area network (s12mscanv3) 18.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 585
mc9s12g family reference manual, rev.1.23 28 freescale semiconductor 18.1.1 glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 586 18.1.2 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 586 18.1.3 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 587 18.1.4 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 587 18.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 587 18.2.1 rxcan ?can receiver input pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 587 18.2.2 txcan ?can transmitter output pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 588 18.2.3 can system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 588 18.3 memory map and register de?ition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 588 18.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 588 18.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 590 18.3.3 programmers model of message storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 609 18.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 618 18.4.1 general . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 618 18.4.2 message storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 619 18.4.3 identi?r acceptance filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 2 18.4.4 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 628 18.4.5 low-power options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 30 18.4.6 reset initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 634 18.4.7 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 634 18.5 initialization/application information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 636 18.5.1 mscan initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 36 18.5.2 bus-off recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 636 chapter 19 pulse-width modulator (s12pwm8b8cv2) 19.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 637 19.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 637 19.1.2 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 637 19.1.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 638 19.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 638 19.2.1 pwm7 - pwm0 ?pwm channel 7 - 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 638 19.3 memory map and register de?ition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 639 19.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 639 19.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 639 19.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 654 19.4.1 pwm clock select . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 654 19.4.2 pwm channel timers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 657 19.5 resets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 664 19.6 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 665 chapter 20 serial communication interface (s12sciv5) 20.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 667
mc9s12g family reference manual, rev.1.23 freescale semiconductor 29 20.1.1 glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 667 20.1.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 668 20.1.3 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 668 20.1.4 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 669 20.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 669 20.2.1 txd ?transmit pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 9 20.2.2 rxd ?receive pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 9 20.3 memory map and register de?ition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 669 20.3.1 module memory map and register de?ition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 670 20.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 670 20.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 681 20.4.1 infrared interface submodule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 682 20.4.2 lin support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 683 20.4.3 data format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 683 20.4.4 baud rate generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 85 20.4.5 transmitter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 686 20.4.6 receiver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 691 20.4.7 single-wire operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 99 20.4.8 loop operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 700 20.5 initialization/application information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 700 20.5.1 reset initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 700 20.5.2 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 700 20.5.3 interrupt operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 701 20.5.4 recovery from wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 703 20.5.5 recovery from stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 703 chapter 21 serial peripheral interface (s12spiv5) 21.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 705 21.1.1 glossary of terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 705 21.1.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 705 21.1.3 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 706 21.1.4 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 706 21.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 707 21.2.1 mosi ?master out/slave in pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 707 21.2.2 miso ?master in/slave out pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 708 21.2.3 ss ?sla v e select pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 708 21.2.4 sck ?serial clock pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 708 21.3 memory map and register de?ition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 708 21.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 708 21.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 709 21.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 717 21.4.1 master mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 718 21.4.2 slave mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 719 21.4.3 transmission formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 20
mc9s12g family reference manual, rev.1.23 30 freescale semiconductor 21.4.4 spi baud rate generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 726 21.4.5 special features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 727 21.4.6 error conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 728 21.4.7 low power mode options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 729 chapter 22 timer module (tim16b6cv3) 22.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 733 22.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 733 22.1.2 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 733 22.1.3 block diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 734 22.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 735 22.2.1 ioc5 - ioc0 ?input capture and output compare channel 5-0 . . . . . . . . . . . . . . . . 735 22.3 memory map and register de?ition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 735 22.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 735 22.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 735 22.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 747 22.4.1 prescaler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 748 22.4.2 input capture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 749 22.4.3 output compare . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 749 22.5 resets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 750 22.6 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 750 22.6.1 channel [5:0] interrupt (c[5:0]f) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 750 22.6.2 timer over?w interrupt (tof) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 750 chapter 23 timer module (tim16b8cv3) 23.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 751 23.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 751 23.1.2 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 752 23.1.3 block diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 752 23.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 755 23.2.1 ioc7 ?input capture and output compare channel 7 . . . . . . . . . . . . . . . . . . . . . . . . 755 23.2.2 ioc6 - ioc0 ?input capture and output compare channel 6-0 . . . . . . . . . . . . . . . . 755 23.3 memory map and register de?ition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 755 23.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 755 23.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 756 23.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 772 23.4.1 prescaler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 774 23.4.2 input capture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 774 23.4.3 output compare . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 774 23.4.4 pulse accumulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 775 23.4.5 event counter mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 76 23.4.6 gated time accumulation mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 776
mc9s12g family reference manual, rev.1.23 freescale semiconductor 31 23.5 resets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 776 23.6 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 776 23.6.1 channel [7:0] interrupt (c[7:0]f) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 777 23.6.2 pulse accumulator input interrupt (paovi) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 777 23.6.3 pulse accumulator over?w interrupt (paovf) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 777 23.6.4 timer over?w interrupt (tof) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 777 chapter 24 16 kbyte flash module (s12ftmrg16k1v1) 24.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 779 24.1.1 glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 780 24.1.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 780 24.1.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 781 24.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 782 24.3 memory map and registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 783 24.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 783 24.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 786 24.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 803 24.4.1 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 803 24.4.2 ifr version id word . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 03 24.4.3 internal nvm resource (nvmres) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 803 24.4.4 flash command operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 803 24.4.5 allowed simultaneous p-flash and eeprom operations . . . . . . . . . . . . . . . . . . . . . . 808 24.4.6 flash command description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 809 24.4.7 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 823 24.4.8 wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 824 24.4.9 stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 824 24.5 security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 824 24.5.1 unsecuring the mcu using backdoor key access . . . . . . . . . . . . . . . . . . . . . . . . . . . . 824 24.5.2 unsecuring the mcu in special single chip mode using bdm . . . . . . . . . . . . . . . . . 825 24.5.3 mode and security effects on flash command availability . . . . . . . . . . . . . . . . . . . . . 826 24.6 initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 826 chapter 25 32 kbyte flash module (s12ftmrg32k1v1) 25.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 827 25.1.1 glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 828 25.1.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 828 25.1.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 829 25.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 830 25.3 memory map and registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 831 25.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 831 25.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 834 25.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 853
mc9s12g family reference manual, rev.1.23 32 freescale semiconductor 25.4.1 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 853 25.4.2 ifr version id word . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 53 25.4.3 internal nvm resource (nvmres) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 854 25.4.4 flash command operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 854 25.4.5 allowed simultaneous p-flash and eeprom operations . . . . . . . . . . . . . . . . . . . . . . 859 25.4.6 flash command description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 860 25.4.7 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 874 25.4.8 wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 875 25.4.9 stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 875 25.5 security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 875 25.5.1 unsecuring the mcu using backdoor key access . . . . . . . . . . . . . . . . . . . . . . . . . . . . 875 25.5.2 unsecuring the mcu in special single chip mode using bdm . . . . . . . . . . . . . . . . . 876 25.5.3 mode and security effects on flash command availability . . . . . . . . . . . . . . . . . . . . . 877 25.6 initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 877 chapter 26 48 kbyte flash module (s12ftmrg48k1v1) 26.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 879 26.1.1 glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 880 26.1.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 880 26.1.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 882 26.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 882 26.3 memory map and registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 883 26.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 883 26.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 887 26.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 906 26.4.1 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 906 26.4.2 ifr version id word . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 06 26.4.3 internal nvm resource (nvmres) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 907 26.4.4 flash command operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 907 26.4.5 allowed simultaneous p-flash and eeprom operations . . . . . . . . . . . . . . . . . . . . . . 912 26.4.6 flash command description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 913 26.4.7 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 927 26.4.8 wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 928 26.4.9 stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 928 26.5 security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 928 26.5.1 unsecuring the mcu using backdoor key access . . . . . . . . . . . . . . . . . . . . . . . . . . . . 928 26.5.2 unsecuring the mcu in special single chip mode using bdm . . . . . . . . . . . . . . . . . 929 26.5.3 mode and security effects on flash command availability . . . . . . . . . . . . . . . . . . . . . 930 26.6 initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 930 chapter 27 64 kbyte flash module (s12ftmrg64k1v1) 27.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 931
mc9s12g family reference manual, rev.1.23 freescale semiconductor 33 27.1.1 glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 932 27.1.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 932 27.1.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 933 27.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 934 27.3 memory map and registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 935 27.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 935 27.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 938 27.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 957 27.4.1 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 957 27.4.2 ifr version id word . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 57 27.4.3 internal nvm resource (nvmres) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 958 27.4.4 flash command operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 958 27.4.5 allowed simultaneous p-flash and eeprom operations . . . . . . . . . . . . . . . . . . . . . . 963 27.4.6 flash command description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 964 27.4.7 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 978 27.4.8 wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 979 27.4.9 stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 979 27.5 security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 979 27.5.1 unsecuring the mcu using backdoor key access . . . . . . . . . . . . . . . . . . . . . . . . . . . . 979 27.5.2 unsecuring the mcu in special single chip mode using bdm . . . . . . . . . . . . . . . . . 980 27.5.3 mode and security effects on flash command availability . . . . . . . . . . . . . . . . . . . . . 981 27.6 initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 981 chapter 28 96 kbyte flash module (s12ftmrg96k1v1) 28.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 983 28.1.1 glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 984 28.1.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 984 28.1.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 985 28.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 986 28.3 memory map and registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 987 28.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 987 28.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 990 28.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1009 28.4.1 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 09 28.4.2 ifr version id word . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 9 28.4.3 internal nvm resource (nvmres) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1010 28.4.4 flash command operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1010 28.4.5 allowed simultaneous p-flash and eeprom operations . . . . . . . . . . . . . . . . . . . . . 1015 28.4.6 flash command description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1016 28.4.7 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1030 28.4.8 wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1031 28.4.9 stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1031 28.5 security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1031 28.5.1 unsecuring the mcu using backdoor key access . . . . . . . . . . . . . . . . . . . . . . . . . . . 1031
mc9s12g family reference manual, rev.1.23 34 freescale semiconductor 28.5.2 unsecuring the mcu in special single chip mode using bdm . . . . . . . . . . . . . . . . 1032 28.5.3 mode and security effects on flash command availability . . . . . . . . . . . . . . . . . . . . 1033 28.6 initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1033 chapter 29 128 kbyte flash module (s12ftmrg128k1v1) 29.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1035 29.1.1 glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1036 29.1.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1036 29.1.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1037 29.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1038 29.3 memory map and registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1039 29.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1039 29.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 043 29.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1061 29.4.1 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 61 29.4.2 ifr version id word . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 1 29.4.3 internal nvm resource (nvmres) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1062 29.4.4 flash command operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1062 29.4.5 allowed simultaneous p-flash and eeprom operations . . . . . . . . . . . . . . . . . . . . . 1067 29.4.6 flash command description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1068 29.4.7 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1082 29.4.8 wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1083 29.4.9 stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1083 29.5 security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1083 29.5.1 unsecuring the mcu using backdoor key access . . . . . . . . . . . . . . . . . . . . . . . . . . . 1083 29.5.2 unsecuring the mcu in special single chip mode using bdm . . . . . . . . . . . . . . . . 1084 29.5.3 mode and security effects on flash command availability . . . . . . . . . . . . . . . . . . . . 1085 29.6 initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1085 chapter 30 192 kbyte flash module (s12ftmrg192k2v1) 30.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1087 30.1.1 glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1088 30.1.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1088 30.1.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1089 30.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1090 30.3 memory map and registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1091 30.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1091 30.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 095 30.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1113 30.4.1 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 13 30.4.2 ifr version id word . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 3 30.4.3 internal nvm resource (nvmres) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1114
mc9s12g family reference manual, rev.1.23 freescale semiconductor 35 30.4.4 flash command operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1114 30.4.5 allowed simultaneous p-flash and eeprom operations . . . . . . . . . . . . . . . . . . . . . 1119 30.4.6 flash command description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1120 30.4.7 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1133 30.4.8 wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1134 30.4.9 stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1134 30.5 security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1135 30.5.1 unsecuring the mcu using backdoor key access . . . . . . . . . . . . . . . . . . . . . . . . . . . 1135 30.5.2 unsecuring the mcu in special single chip mode using bdm . . . . . . . . . . . . . . . . 1136 30.5.3 mode and security effects on flash command availability . . . . . . . . . . . . . . . . . . . . 1136 30.6 initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1136 chapter 31 240 kbyte flash module (s12ftmrg240k2v1) 31.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1139 31.1.1 glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1140 31.1.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1140 31.1.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1141 31.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1142 31.3 memory map and registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1143 31.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1143 31.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 147 31.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1165 31.4.1 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 65 31.4.2 ifr version id word . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 5 31.4.3 internal nvm resource (nvmres) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1166 31.4.4 flash command operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1166 31.4.5 allowed simultaneous p-flash and eeprom operations . . . . . . . . . . . . . . . . . . . . . 1171 31.4.6 flash command description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1172 31.4.7 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1185 31.4.8 wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1186 31.4.9 stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1186 31.5 security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1187 31.5.1 unsecuring the mcu using backdoor key access . . . . . . . . . . . . . . . . . . . . . . . . . . . 1187 31.5.2 unsecuring the mcu in special single chip mode using bdm . . . . . . . . . . . . . . . . 1188 31.5.3 mode and security effects on flash command availability . . . . . . . . . . . . . . . . . . . . 1188 31.6 initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1188 appendix a electrical characteristics a.1 general . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1192 a.1.1 parameter classification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 2 a.1.2 power supply . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1192 a.1.3 pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1193
mc9s12g family reference manual, rev.1.23 36 freescale semiconductor a.1.4 current injection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1193 a.1.5 absolute maximum ratings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1194 a.1.6 esd protection and latch-up immunity. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1194 a.1.7 operating conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 95 a.1.8 power dissipation and thermal characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1197 a.2 i/o characteristics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1201 a.3 supply currents. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1205 a.3.1 measurement conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1205 a.4 adc characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1210 a.4.1 adc operating characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1210 a.4.2 factors influencing accuracy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1211 a.4.3 adc accuracy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1212 a.4.4 adc temperature sensor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1222 a.5 acmp characteristics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1222 a.6 dac characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1224 a.7 nvm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1225 a.7.1 timing parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 225 a.7.2 nvm reliability parameters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1233 a.8 phase locked loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1234 a.8.1 jitter definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1234 a.8.2 electrical characteristics for the pll. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1236 a.9 electrical characteristics for the irc1m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1236 a.10 electrical characteristics for the oscillator (xosclcp). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1238 a.11 reset characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1239 a.12 electrical specification for voltage regulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 40 a.13 chip power-up and voltage drops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1242 a.14 mscan. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1242 a.15 spi timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1243 a.15.1 master mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1243 a.15.2 slave mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1245 a.16 adc conversion result reference. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1247 appendix b detailed register address map b.1 detailed register map. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1249 appendix c ordering and shipping information c.1 ordering information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1269 appendix d package and die information d.1 100 lqfp mechanical dimensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 72 d.2 64 lqfp mechanical dimensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 275
mc9s12g family reference manual, rev.1.23 freescale semiconductor 37 d.3 48 lqfp mechanical dimensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 278 d.4 48 qfn mechanical dimensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1280 d.5 32 lqfp mechanical dimensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 283 d.6 20 tssop mechanical dimensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 86 d.7 kgd information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1289
mc9s12g family reference manual, rev.1.23 38 freescale semiconductor
mc9s12g family reference manual, rev.1.23 freescale semiconductor 39 chapter 1 device overview mc9s12g-family revision history 1.1 introduction the mc9s12g-family is an optimized, automotive, 16-bit microcontroller product line focused on low-cost, high-performance, and low pin-count. this family is intended to bridge between high-end 8-bit microcontrollers and high-performance 16-bit microcontrollers, such as the mc9s12xs-family. the mc9s12g-family is targeted at generic automotive applications requiring can or lin/j2602 version number revision date description of changes rev 0.25 18-feb-2011 added section 1.14, ?utonomous clock (aclk) con?uration corrected figure 1-15 corrected figure 1-10 corrected figure 1-16 corrected figure 1-12 typos and formatting rev 0.26 21-feb-2011 updated table 1-1 (added temperatur sensor feature) updated section 1.3.14, ?nalog-to-digital converter module (adc) updated table 1-38 typos and formatting rev 0.27 1-apr-2011 typos and formatting rev 0.28 11-may-2011 rev 0.29 10-jan-2011 corrected figure 1-4 rev 0.30 10-feb-2012 updated table 1-5 (added mask set 1n75c) typos and formatting rev 0.31 15-mar-2012 updated table 1-1 (added s12gsa devices) updated figure 1-1 updated table 1-5 (added s12ga devices) added section 1.8.2, ?12gna16 and s12gna32 added section 1.8.5, ?12ga48 and s12ga64 added section 1.8.7, ?12ga96 and s12ga128 typos and formatting rev 0.32 07-may-2012 updated section 1.19, ?dm clock source connectivity typos and formatting rev 0.33 27-sep-2012 corrected figure 1-4 corrected figure 1-5 corrected figure 1-6 rev 0.34 25-jan-2013 added kgd option for the s12ga192 and the s12ga240 updated table 1-1 corrected table 1-2 corrected table 1-6
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 40 freescale semiconductor communication. typical examples of these applications include body controllers, occupant detection, door modules, seat controllers, rke receivers, smart actuators, lighting modules, and smart junction boxes. the mc9s12g-family uses many of the same features found on the mc9s12xs- and mc9s12p-family, including error correction code (ecc) on ?sh memory, a fast analog-to-digital converter (adc) and a frequency modulated phase locked loop (ipll) that improves the emc performance. the mc9s12g-family is optimized for lower program memory sizes down to 16k. in order to simplify customer use it features an eeprom with a small 4 bytes erase sector size. the mc9s12g-family deliver all the advantages and ef?iencies of a 16-bit mcu while retaining the low cost, power consumption, emc, and code-size ef?iency advantages currently enjoyed by users of freescales existing 8-bit and 16-bit mcu families. like the mc9s12xs-family, the mc9s12g-family run 16-bit wide accesses without wait states for all peripherals and memories. the mc9s12g-family is available in 100-pin lqfp, 64-pin lqfp, 48-pin lqfp/qfn, 32-pin lqfp and 20-pin tssop package options and aims to maximize the amount of functionality especially for the lower pin count packages. in addition to the i/o ports available in each module, further i/o ports are available with interrupt capability allowing wake-up from stop or wait modes. 1.2 features this section describes the key features of the mc9s12g-family. 1.2.1 mc9s12g-family comparison table 1-1 provides a summary of different members of the mc9s12g-family and their features. this information is intended to provide an understanding of the range of functionality offered by this microcontroller family. table 1-1. mc9s12g-family overview 1 feature s12gn16 s12gna16 s12gn32 s12gna32 s12gn48 s12g48 s12ga48 s12g64 s12ga64 s12g96 s12ga96 s12g128 s12ga128 s12g192 s12ga192 s12g240 s12ga240 cpu cpu12v1 flash memory [kbytes] 16 16 32 32 48 48 48 64 64 96 96 128 128 192 192 240 240 eeprom [kbytes] 0.5 0.5 1 1 1.5 1.5 1.5 2233444444 ram [kbytes] 112244444888811111111 mscan 111111111111 sci 11112222233333333 spi 11112222233333333 16-bit timer channels 66666666688888888 8-bit pwm channels 66666666688888888 10-bit adc channels 8 8 12 12 12 12 12 16 16
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 41 table 1-2 shows the maximum number of peripherals or peripheral channels per package type. not all peripherals are available at the same time. the maximum number of peripherals is also limited by the device chosen as per table 1-1 . 12-bit adc channels 8 8 12 12 12 12 16 16 temperature sensor yesyes rva yesyes 8-bit dac 2 2 acmp (analog comparator) 111111111 pll yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes external osc yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes internal 1 mhz rc oscillator ye s ye s ye s ye s ye s ye s ye s ye s ye s ye s ye s ye s ye s ye s ye s ye s ye s 20-pin tssop yes yes 32-pin lqfp yes yes yes yes yes 48-pin lqfp yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes 48-pin qfn yes yes yes yes 64-pin lqfp yesyesyesyesyesyesyesyesyesyesyesyesyes 100-pin lqfp yesyesyesyesyesyesyesyes kgd yesyes supply voltage 3.13 v ?5.5 v execution speed static ?25 mhz 1 not all peripherals are available in all package types table 1-2. maximum peripheral availability per package peripheral 20 tssop 32 lqfp 48 lqfp, 48 qfn 64 lqfp 100 lqfp kgd (die) mscan yes yes yes yes yes sci0 yes yes yes yes yes yes sci1 yes yes yes yes yes sci2 yes yes yes yes spi0 yes yes yes yes yes yes spi1 yes yes yes yes spi2 yes yes yes timer channels 4 = 0 ?3 6 = 0 ?5 8 = 0 ?7 8 = 0 ?7 8 = 0 ?7 8 = 0 ?7 table 1-1. mc9s12g-family overview 1 feature s12gn16 s12gna16 s12gn32 s12gna32 s12gn48 s12g48 s12ga48 s12g64 s12ga64 s12g96 s12ga96 s12g128 s12ga128 s12g192 s12ga192 s12g240 s12ga240
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 42 freescale semiconductor 1.2.2 chip-level features on-chip modules available within the family include the following features: s12 cpu core up to 240 kbyte on-chip ?sh with ecc up to 4 kbyte eeprom with ecc up to 11 kbyte on-chip sram phase locked loop (ipll) frequency multiplier with internal ?ter 4?6 mhz amplitude controlled pierce oscillator 1 mhz internal rc oscillator timer module (tim) supporting up to eight channels that provide a range of 16-bit input capture, output compare, counter, and pulse accumulator functions pulse width modulation (pwm) module with up to eight x 8-bit channels up to 16-channel, 10 or 12-bit resolution successive approximation analog-to-digital converter (adc) up to two 8-bit digital-to-analog converters (dac) up to one 5v analog comparator (acmp) up to three serial peripheral interface (spi) modules up to three serial communication interface (sci) modules supporting lin communications up to one multi-scalable controller area network (mscan) module (supporting can protocol 2.0a/b) on-chip voltage regulator (vreg) for regulation of input supply and all internal voltages autonomous periodic interrupt (api) precision ?ed voltage reference for adc conversions optional reference voltage attenuator module to increase adc accuracy 1.3 module features the following sections provide more details of the modules implemented on the mc9s12g-family family. 8-bit pwm channels 4 = 0 ?3 6 = 0 ?5 8 = 0 ?7 8 = 0 ?7 8 = 0 ?7 8 = 0 ?7 adc channels 6 = 0 ?5 8 = 0 ?7 12 = 0 ?11 16 = 0 ?15 16 = 0 ?15 16 = 0 ?15 dac0 yes yes yes yes dac1 yes yes yes yes acmp yes yes yes yes total gpio 14 26 40 54 86 86 table 1-2. maximum peripheral availability per package peripheral 20 tssop 32 lqfp 48 lqfp, 48 qfn 64 lqfp 100 lqfp kgd (die)
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 43 1.3.1 s12 16-bit central processor unit (cpu) s12 cpu is a high-speed 16-bit processing unit: full 16-bit data paths supports ef?ient arithmetic operation and high-speed math execution includes many single-byte instructions. this allows much more ef?ient use of rom space. extensive set of indexed addressing capabilities, including: using the stack pointer as an indexing register in all indexed operations using the program counter as an indexing register in all but auto increment/decrement mode accumulator offsets using a, b, or d accumulators automatic index predecrement, preincrement, postdecrement, and postincrement (by ? to +8) 1.3.2 on-chip flash with ecc on-chip ?sh memory on the mc9s12g-family family features the following: up to 240 kbyte of program ?sh memory 32 data bits plus 7 syndrome ecc (error correction code) bits allow single bit error correction and double fault detection erase sector size 512 bytes automated program and erase algorithm user margin level setting for reads protection scheme to prevent accidental program or erase up to 4 kbyte eeprom 16 data bits plus 6 syndrome ecc (error correction code) bits allow single bit error correction and double fault detection erase sector size 4 bytes automated program and erase algorithm user margin level setting for reads 1.3.3 on-chip sram up to 11 kbytes of general-purpose ram 1.3.4 port integration module (pim) data registers and data direction registers for ports a, b, c, d, e, t, s, m, p, j and ad when used as general-purpose i/o control registers to enable/disable pull devices and select pullups/pulldowns on ports t, s, m, p, j and ad on per-pin basis single control register to enable/disable pull devices on ports a, b, c, d and e, on per-port basis and on bkgd pin control registers to enable/disable open-drain (wired-or) mode on ports s and m
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 44 freescale semiconductor interrupt ?g register for pin interrupts on ports p, j and ad control register to con?ure irq pin operation routing register to support programmable signal redirection in 20 tssop only routing register to support programmable signal redirection in 100 lqfp package only package code register preset by factory related to package in use, writable once after reset. also includes bit to reprogram routing of api_extclk in all packages. control register for free-running clock outputs 1.3.5 main external oscillator (xosclcp) loop control pierce oscillator using a 4 mhz to 16 mhz crystal current gain control on amplitude output signal with low harmonic distortion low power good noise immunity eliminates need for external current limiting resistor transconductance sized for optimum start-up margin for typical crystals oscillator pins can be shared w/ gpio functionality 1.3.6 internal rc oscillator (irc) trimmable internal reference clock. frequency: 1 mhz trimmed accuracy over ?0?c to +125?c ambient temperature range: 1.0% for temperature option c and v (see table a-4 ) 1.3% for temperature option m (see table a-4 ) 1.3.7 internal phase-locked loop (ipll) phase-locked-loop clock frequency multiplier no external components required reference divider and multiplier allow large variety of clock rates automatic bandwidth control mode for low-jitter operation automatic frequency lock detector con?urable option to spread spectrum for reduced emc radiation (frequency modulation) reference clock sources: external 4?6 mhz resonator/crystal (xosclcp) internal 1 mhz rc oscillator (irc)
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 45 1.3.8 system integrity support power-on reset (por) system reset generation illegal address detection with reset low-voltage detection with interrupt or reset real time interrupt (rti) computer operating properly (cop) watchdog con?urable as window cop for enhanced failure detection initialized out of reset using option bits located in ?sh memory clock monitor supervising the correct function of the oscillator 1.3.9 timer (tim) up to eight x 16-bit channels for input capture or output compare 16-bit free-running counter with 7-bit precision prescaler in case of eight channel timer version an additional 16-bit pulse accumulator is available 1.3.10 pulse width modulation module (pwm) up to eight channel x 8-bit or up to four channel x 16-bit pulse width modulator programmable period and duty cycle per channel center-aligned or left-aligned outputs programmable clock select logic with a wide range of frequencies 1.3.11 controller area network module (mscan) 1 mbit per second, can 2.0 a, b software compatible standard and extended data frames 0? bytes data length programmable bit rate up to 1 mbps five receive buffers with fifo storage scheme three transmit buffers with internal prioritization flexible identi?r acceptance ?ter programmable as: 2 x 32-bit 4 x 16-bit 8 x 8-bit wakeup with integrated low pass ?ter option loop back for self test listen-only mode to monitor can bus
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 46 freescale semiconductor bus-off recovery by software intervention or automatically 16-bit time stamp of transmitted/received messages 1.3.12 serial communication interface module (sci) up to three sci modules full-duplex or single-wire operation standard mark/space non-return-to-zero (nrz) format selectable irda 1.4 return-to-zero-inverted (rzi) format with programmable pulse widths 13-bit baud rate selection programmable character length programmable polarity for transmitter and receiver active edge receive wakeup break detect and transmit collision detect supporting lin 1.3, 2.0, 2.1 and sae j2602 1.3.13 serial peripheral interface module (spi) up to three spi modules con?urable 8- or 16-bit data size full-duplex or single-wire bidirectional double-buffered transmit and receive master or slave mode msb-?st or lsb-?st shifting serial clock phase and polarity options 1.3.14 analog-to-digital converter module (adc) up to 16-channel, 10-bit/12-bit 1 analog-to-digital converter 3 us conversion time 8-/10 1 -bit resolution left or right justi?d result data wakeup from low power modes on analog comparison > or <= match continuous conversion mode external triggers to initiate conversions via gpio or peripheral outputs such as pwm or tim multiple channel scans precision ?ed voltage reference for adc conversions pins can also be used as digital i/o including wakeup capability 1. 12-bit resolution only available on s12ga192 and s12ga240 devices.
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 47 1.3.15 reference voltage attenuator (rva) attenuation of adc reference voltage with low long-term drift 1.3.16 digital-to-analog converter module (dac) 1 digital-analog converter channel (per module) with: 8 bit resolution full and reduced output voltage range buffered or unbuffered analog output voltage usable operational ampli?r stand alone usable 1.3.17 analog comparator (acmp) low offset, low long-term offset drift selectable interrupt on rising, falling, or rising and falling edges of comparator output option to output comparator signal on an external pin option to trigger timer input capture events 1.3.18 on-chip voltage regulator (vreg) linear voltage regulator with bandgap reference low-voltage detect (lvd) with low-voltage interrupt (lvi) power-on reset (por) circuit low-voltage reset (lvr) 1.3.19 background debug (bdm) non-intrusive memory access commands supports in-circuit programming of on-chip nonvolatile memory 1.3.20 debugger (dbg) trace buffer with depth of 64 entries three comparators (a, b and c) access address comparisons with optional data comparisons program counter comparisons exact address or address range comparisons two types of comparator matches tagged this matches just before a speci? instruction begins execution force this is valid on the ?st instruction boundary after a match occurs four trace modes
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 48 freescale semiconductor four stage state sequencer 1.4 key performance parameters the key performance parameters of s12g devices feature: continuous operating voltage of 3.15 v to 5.5 v operating temperature (t a ) of ?0?c to 125?c junction temperature (t j ) of up to 150?c bus frequency (f bus ) of dc to 25 mhz packaging: 100-pin lqfp, 0.5 mm pitch, 14 mm x 14 mm outline 64-pin lqfp, 0.5 mm pitch, 10 mm x 10 mm outline 48-pin lqfp, 0.5 mm pitch, 7 mm x 7 mm outline 48-pin qfn, 0.5 mm pitch, 7 mm x 7 mm outline 32-pin lqfp, 0.8 mm pitch, 7 mm x 7 mm outline 20 tssop, 0.65 mm pitch, 4.4 mm x 6.5 mm outline known good die (kgd), unpackaged 1.5 block diagram figure 1-1 shows a block diagram of the mc9s12g-family.
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 49 figure 1-1. mc9s12g-family block diagram 1.6 family memory map table 1-3 shows the mc9s12g-family register memory map. table 1-3. device register memory map address module size (bytes) 0x0000?x0009 pim (port integration module ) 10 1k ?11k bytes ram reset extal xtal 0.5k ?4k bytes eeprom with ecc bkgd vddr real time interrupt clock monitor single-wire background test debug module adc interrupt module (wu int) sci0 ps3 ps0 ps1 ps2 pts an[15:0] pad[15:0] 8...16 ch. 16-bit 6 ?8 channel timer tim asynchronous serial if 8-bit 6 ?8 channel pulse width modulator pwm pb[7:0] ptb pa[7:0] pta 16k ?240k bytes flash with ecc cpu12-v1 cop watchdog pll with frequency modulation option debug module 3 comparators 64 byte trace buffer reset generation and test entry rxd txd pj2 ptj (wake-up int) can pm3 pm0 pm1 pm2 ptm mscan 2.0b rxcan txcan auton. periodic int. pj7 pj6 pt3 pt0 pt1 pt2 ptt pt7 pt4 pt5 pt6 pp3 pp0 pp1 pp2 ptp (wake-up int) pp7 pp4 pp5 pwm3 pwm0 pwm1 pwm2 pwm4 pwm5 ioc3 ioc0 ioc1 ioc2 ioc7 ioc4 ioc5 ioc6 vdda vssa vrh vddx1/vssx1 vddx2/vssx2 pj0 pj1 3-5v io supply vss low power pierce oscillator pp6 pwm6 pwm7 sci1 asynchronous serial if rxd txd mosi ss sck miso spi0 synchronous serial if ps4 ps5 ps6 ps7 sci2 asynchronous serial if rxd txd voltage regulator input: 3.13v ?5.5v block diagram shows the maximum configuration! mosi ss sck miso spi1 synchronous serial if mosi ss sck miso spi2 synchronous serial if pj3 pj4 pj5 pd[7:0] ptd pc[7:0] ptc vddx3/vssx3 not all pins or all peripherals are available on all devices and packages. rerouting options are not shown. pe0 pte pe1 ptad analog-digital converter acmp analog comparator dac0 digital-analog converter ampm amp dacu ampp dac1 digital-analog converter 12-bit or 10-bit rva internal rc oscillator
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 50 freescale semiconductor 0x000a?x000b mmc (memory map control) 2 0x000c?x000d pim (port integration module) 2 0x000e?x000f reserved 2 0x0010?x0017 mmc (memory map control) 8 0x0018?x0019 reserved 2 0x001a?x001b device id register 2 0x001c?x001f pim (port integration module) 4 0x0020?x002f dbg (debug module) 16 0x0030?x0033 reserved 4 0x0034?x003f cpmu (clock and power management) 12 0x0040?x006f tim (timer module <= 8 channels) 48 0x0070?x009f adc (analog to digital converter <= 16 channels) 48 0x00a0?x00c7 pwm (pulse-width modulator <= 8 channels) 40 0x00c8?x00cf sci0 (serial communication interface) 8 0x00d0?x00d7 sci1 (serial communication interface) 1 8 0x00d8?x00df spi0 (serial peripheral interface) 8 0x00e0?x00e7 reserved 8 0x00e8?x00ef sci2 (serial communication interface) 2 8 0x00f0?x00f7 spi1 (serial peripheral interface) 3 8 0x00f8?x00ff spi2 (serial peripheral interface) 4 8 0x0100?x0113 ftmrg control registers 20 0x0114?x011f reserved 12 0x0120 int (interrupt module) 1 0x0121?x013f reserved 31 0x0140?x017f can 5 64 0x0180?x023f reserved 192 0x0240?x025f pim (port integration module) 32 0x0260?x0261 acmp (analog comparator) 6 2 0x0262?x0275 pim (port integration module) 20 0x0276 rva (reference voltage attenuator) 7 1 0x0277?x027f pim (port integration module) 9 0x0280?x02ef reserved 112 0x02f0?x02ff cpmu (clock and power management) 16 0x0300?x03bf reserved 192 0x03c0?x03c7 dac0 (digital to analog converter) 8 8 address module size (bytes)
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 51 note reserved register space shown in table 1-3 is not allocated to any module. this register space is reserved for future use. writing to these locations has no effect. read access to these locations returns zero. figure 1-2 shows s12g cpu and bdm local address translation to the global memory map as a graphical representation. in conjunction table 1-4 shows the address ranges and mapping to 256k global memory space for p-flash, eeprom and ram. the whole 256k global memory space is visible through the p-flash window located in the 64k local memory map located at 0x8000 - 0xbfff using the ppage register. 0x03c8?x03cf dac1 (digital to analog converter) 8 8 0x03d0?x03ff reserved 48 1 the sci1 is not available on the s12gn8, s12gn16, s12gn32, and s12gn32 devices 2 the sci2 is not available on the s12gn8, s12gn16, s12gn32, s12gn32, s12g48, and s12g64 devices 3 the spi1 is not available on the s12gn8, s12gn16, s12gn24, and s12gn32 devices 4 the spi2 is not available on the s12gn8, s12gn16, s12gn32, s12gn32, s12g48, and s12g64 devices 5 the can is not available on the s12gn8, s12gn16, s12gn24, s12gn32, and s12gn48 devices 6 the acmp is only available on the s12gn8, s12gn16, s12gn24, s12gn32, s12gn48,s12gn48, s12g48, and s12g64 devices 7 the rva is only available on the s12ga192 and s12ga240 devices 8 dac0 and dac1 are only available on the s12ga192 and s12ga240 devices table 1-4. mc9s12g-family memory parameters feature s12gn16 s12gn32 s12g48 s12gn48 s12g64 s12g96 s12g128 s12g192 s12ga192 s12g240 s12ga240 p-flash size 16kb 32kb 48kb 64kb 96kb 128kb 192kb 240kb pf_low 0x3c000 0x38000 0x34000 0x30000 0x28000 0x20000 0x10000 0x04000 pf_low_unp (unpaged) 1 0xc000 0x8000 0x4000 ppages 0x0f 0x0e - 0x0f 0x0d - 0x0f 0x0c - 0x0f 0x0a - 0x0f 0x08 - 0x0f 0x04 - 0x0f 0x01 - 0x0f eeprom [bytes] 512 1024 1536 2048 3072 4096 4096 4096 eeprom_hi 0x05ff 0x07ff 0x09ff 0x0bff 0x0fff 0x13ff 0x13ff 0x13ff address module size (bytes)
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 52 freescale semiconductor ram [bytes] 1024 2048 4096 4096 8192 8192 11264 11264 ram_low 0x3c00 0x3800 0x3000 0x3000 0x2000 0x2000 0x1400 0x1400 unpaged flash space left 2 0x0c00- 0x2fff 0x1000- 0x1fff 0x1400- 0x1fff unpaged flash 2 9kb 4kb 3kb 1 while for memory sizes <64k the whole 256k space could be addressed using the ppage, it is more ef?ient to use an unpaged memory model 2 page 0xc table 1-4. mc9s12g-family memory parameters feature s12gn16 s12gn32 s12g48 s12gn48 s12g64 s12g96 s12g128 s12g192 s12ga192 s12g240 s12ga240
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 53 figure 1-2. mc9s12g global memory map paging window 0x3_ffff local cpu and bdm memory map global memory map 0xffff 0xc000 0x0_0400 0x0_0000 0x3_c000 0x0000 0x8000 0x0400 0x4000 0x0_4000 paging window flash space flash space ram ram unimplemented unimplemented flash space flash space flash space flash space flash space flash space register space register space internal nvm resources internal nvm resources flash space flash space flash space flash space flash space flash space flash space flash space eeprom eeprom eeprom eeprom page 0x1 page 0x1 page 0xf page 0xf page 0xd page 0xd register space register space page 0xc page 0xc page 0xe page 0xe page 0xf page 0xf page 0xd page 0xd page 0xc page 0xc nvmres=0 nvmres=0 nvmres=1 nvmres=1 flash space flash space page 0x2 page 0x2 0x3_0000 0x3_4000 0x3_8000 0x0_8000 ram ram
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 54 freescale semiconductor 1.6.1 part id assignments the part id is located in two 8-bit registers partidh and partidl (addresses 0x001a and 0x001b). the read-only value is a unique part id for each revision of the chip. table 1-5 shows the assigned part id number and mask set number. 1.7 signal description and device pinouts this section describes signals that connect off-chip. it includes a pinout diagram, a table of signal properties, and detailed discussion of signals. it is built from the signal description sections of the individual ip blocks on the device. table 1-5. assigned part id numbers device mask set number part id mc9s12ga240 0n95b 0xf080 mc9s12g240 0n95b 0xf080 mc9s12ga192 0n95b 0xf080 mc9s12g192 0n95b 0xf080 mc9s12ga128 0n51a 0xf180 mc9s12g128 0n51a 0xf180 mc9s12ga96 0n51a 0xf180 mc9s12g96 0n51a 0xf180 mc9s12ga64 0n75c 0xf280 mc9s12g64 0n75c 1 1 only available in 48-pin lqfp and 64-pin lqfp 0xf280 1 1n75c 2 2 only available in 32-pin lqfp 0xf281 2 mc9s12ga48 0n75c 0xf280 mc9s12g48 0n75c 1 0xf280 1 1n75c 2 0xf281 2 mc9s12gn48 0n75c 1 0xf280 1 1n75c 2 0xf281 2 mc9s12gna32 0n48a 0xf380 mc9s12gn32 0n48a 3 3 only available in 48-pin lqfp and 48-pin qfn 0xf380 3 1n48a 4 4 only available in 20-pin tssop and 32-pin lqfp 0xf381 4 mc9s12gna16 0n48a 0xf380 mc9s12gn16 0n48a 3 0xf380 3 1n48a 4 0xf381 4
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 55 1.7.1 pin assignment overview table 1-6 provides a summary of which ports are available for each package option. note to avoid current drawn from ?ating inputs, the input buffers of all non-bonded pins are disabled. 1.7.2 detailed signal descriptions this section describes the signal properties. the relation between signals and package pins is described in section 1.8 device pinouts . 1.7.2.1 reset ?external reset signal the reset signal is an active low bidirectional control signal. it acts as an input to initialize the mcu to a known start-up state, and an output when an internal mcu function causes a reset. the reset pin has an internal pull-up device. 1.7.2.2 test ?test pin this input only pin is reserved for factory test. this pin has an internal pull-down device. table 1-6. port availability by package option port 20 tssop 32 lqfp 48 lqfp 48 qfn 64 lqfp 100 lqfp kgd (die) port ad/adc channels 6 8 12 16 16 16 port a pins 000088 port b pins 000088 port c pins 000088 port d pins 000088 port e pins 222222 port j 004888 port m 022444 port p 046888 port s 468888 port t 246888 sum of ports 14 26 40 54 86 86 i/o power pairs vddx/vssx 1/1 1/1 1/1 1/1 3/3 3/3
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 56 freescale semiconductor note the test pin must be tied to ground in all applications. 1.7.2.3 bkgd / modc ?background debug and mode pin the bkgd/modc pin is used as a pseudo-open-drain pin for the background debug communication. it is used as a mcu operating mode select pin during reset. the state of this pin is latched to the modc bit at the rising edge of reset. the bkgd pin has an internal pull-up device. 1.7.2.4 extal, xtal ?oscillator signal extal and xtal are the crystal driver and external clock signals. on reset all the device clocks are derived from the internal reference clock. xtal is the oscillator output. 1.7.2.5 pad[15:0] / kwad[15:0] ?port ad input pins of adc pad[15:0] are general-purpose input or output signals. these signals can have a pull-up or pull-down device selected and enabled on per signal basis. out of reset the pull devices are disabled. 1.7.2.6 pa[7:0] ?port a i/o signals pa[7:0] are general-purpose input or output signals. the signals can have pull-up devices, enabled by a single control bit for this signal group. out of reset the pull-up devices are disabled . 1.7.2.7 pb[7:0] ?port b i/o signals pb[7:0] are general-purpose input or output signals. the signals can have pull-up devices, enabled by a single control bit for this signal group. out of reset the pull-up devices are disabled . 1.7.2.8 pc[7:0] ?port c i/o signals pc[7:0] are general-purpose input or output signals. the signals can have pull-up devices, enabled by a single control bit for this signal group. out of reset the pull-up devices are disabled . 1.7.2.9 pd[7:0] ?port d i/o signals pd[7:0] are general-purpose input or output signals. the signals can have pull-up device, enabled by a single control bit for this signal group. out of reset the pull-up devices are disabled. 1.7.2.10 pe[1:0] ?port e i/o signals pe[1:0] are general-purpose input or output signals. the signals can have pull-down device, enabled by a single control bit for this signal group. out of reset the pull-down devices are enabled.
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 57 1.7.2.11 pj[7:0] / kwj[7:0] ?port j i/o signals pj[7:0] are general-purpose input or output signals. the signals can be con?ured on per signal basis as interrupt inputs with wakeup capability (kwj[7:0]). they can have a pull-up or pull-down device selected and enabled on per signal basis. out of reset the pull devices are enabled . 1.7.2.12 pm[3:0] ?port m i/o signals pm[3:0] are general-purpose input or output signals. they can have a pull-up or pull-down device selected and enabled on per signal basis. out of reset the pull devices are disabled. the signals can be con?ured on per pin basis to open-drain mode. 1.7.2.13 pp[7:0] / kwp[7:0] ?port p i/o signals pp[7:0] are general-purpose input or output signals. the signals can be con?ured on per signal basis as interrupt inputs with wakeup capability (kwp[7:0]). they can have a pull-up or pull-down device selected and enabled on per signal basis. out of reset the pull devices are disabled . 1.7.2.14 ps[7:0] ?port s i/o signals ps[7:0] are general-purpose input or output signals. they can have a pull-up or pull-down device selected and enabled on per signal basis. out of reset the pull-up devices are enabled. the signals can be con?ured on per pin basis in open-drain mode. 1.7.2.15 pt[7:0] ?port ti/o signals pt[7:0] are general-purpose input or output signals. they can have a pull-up or pull-down device selected and enabled on per signal basis. out of reset the pull devices are disabled . 1.7.2.16 an[15:0] ?adc input signals an[15:0] are the analog inputs of the analog-to-digital converter. 1.7.2.17 acmp signals 1.7.2.17.1 acmpp ?non-inverting analog comparator input acmpp is the non-inverting input of the analog comparator. 1.7.2.17.2 acmpm ?inverting analog comparator input acmpm is the inverting input of the analog comparator. 1.7.2.17.3 acmpo ?analog comparator output acmpo is the output of the analog comparator.
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 58 freescale semiconductor 1.7.2.18 dac signals 1.7.2.18.1 dacu[1:0] output pins these analog pins is used for the unbuffered analog output voltages from the dac0 and the dac1 resistor network output, when the according mode is selected. 1.7.2.18.2 amp[1:0] output pins these analog pins are used for the buffered analog outputs voltage from the operational ampli?r outputs, when the according mode is selected. 1.7.2.18.3 ampp[1:0] input pins these analog input pins areused as input signals for the operational ampli?rs positive input pins when the according mode is selected. 1.7.2.18.4 ampm[1:0] input pins these analog input pins are used as input signals for the operational ampli?rs negative input pin when the according mode is selected. 1.7.2.19 spi signals 1.7.2.19.1 ss[2:0] signals those signals are associated with the slave select ss functionality of the serial peripheral interfaces spi2-0. 1.7.2.19.2 sck[2:0] signals those signals are associated with the serial clock sck functionality of the serial peripheral interfaces spi2-0. 1.7.2.19.3 miso[2:0] signals those signals are associated with the miso functionality of the serial peripheral interfaces spi2-0. they act as master input during master mode or as slave output during slave mode. 1.7.2.19.4 mosi[2:0] signals those signals are associated with the mosi functionality of the serial peripheral interfaces spi2-0. they act as master output during master mode or as slave input during slave mode. 1.7.2.20 sci signals 1.7.2.20.1 rxd[2:0] signals those signals are associated with the receive functionality of the serial communication interfaces sci2-0.
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 59 1.7.2.20.2 txd[2:0] signals those signals are associated with the transmit functionality of the serial communication interfaces sci2-0. 1.7.2.21 can signals 1.7.2.21.1 rxcan signal this signal is associated with the receive functionality of the scalable controller area network controller (mscan). 1.7.2.21.2 txcan signal this signal is associated with the transmit functionality of the scalable controller area network controller (mscan). 1.7.2.22 pwm[7:0] signals the signals pwm[7:0] are associated with the pwm module outputs. 1.7.2.23 internal clock outputs 1.7.2.23.1 eclk this signal is associated with the output of the divided bus clock (eclk). note this feature is only intended for debug purposes at room temperature. it must not be used for clocking external devices in an application. 1.7.2.23.2 eclkx2 this signal is associated with the output of twice the bus clock (eclkx2). note this feature is only intended for debug purposes at room temperature. it must not be used for clocking external devices in an application. 1.7.2.23.3 api_extclk this signal is associated with the output of the api clock (api_extclk). 1.7.2.24 ioc[7:0] signals the signals ioc[7:0] are associated with the input capture or output compare functionality of the timer (tim) module.
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 60 freescale semiconductor 1.7.2.25 irq this signal is associated with the maskable irq interrupt. 1.7.2.26 xirq this signal is associated with the non-maskable xirq interrupt. 1.7.2.27 etrig[3:0] these signals are inputs to the analog-to-digital converter. their purpose is to trigger adc conversions. 1.7.3 power supply pins mc9s12g power and ground pins are described below. because fast signal transitions place high, short-duration current demands on the power supply, use bypass capacitors with high-frequency characteristics and place them as close to the mcu as possible. note all ground pins must be connected together in the application. 1.7.3.1 vddx[3:1]/vddx, vssx[3:1]/vssx ?power and ground pins for i/o drivers external power and ground for i/o drivers. bypass requirements depend on how heavily the mcu pins are loaded. all vddx pins are connected together internally. all vssx pins are connected together internally. note not all vddx[3:1]/vddx and vssx[3:1]vssx pins are available on all packages. refer to section 1.8 device pinouts for further details. 1.7.3.2 vddr ?power pin for internal voltage regulator power supply input to the internal voltage regulator. note on some packages vddr is bonded to vddx and the pin is named vddxr. refer to section 1.8 device pinouts for further details. 1.7.3.3 vss ?core ground pin the voltage supply of nominally 1.8v is derived from the internal voltage regulator. the return current path is through the vss pin.
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 61 1.7.3.4 vdda, vssa ?power supply pins for dac,acmp, rva, adc and voltage regulator these are the power supply and ground input pins for the digital-to-analog converter, the analog comparator, the reference voltage attenuator, the analog-to-digital converter and the voltage regulator. note on some packages vdda is connected with vddxr and the common pin is named vddxra. on some packages the vssa is connected to vssx and the common pin is named vssxa. see section section 1.8, ?evice pinouts for further details. 1.7.3.5 vrh ?reference voltage input pin v rh is the reference voltage input pin for the digital-to-analog converter and the analog-to-digital converter. refer to section 1.18, adc vrh/vrl signal connection for further details. on some packages vrh is tied to vdda or vddxra. refer to section 1.8 device pinouts for further details. 1.7.3.6 power and ground connection summary table 1-7. power and ground connection summary mnemonic nominal voltage description vddr 3.15v ?5.0 v external power supply for internal voltage regulator. vss 0v return ground for the logic supply generated by the internal regulator vddx [3:1] 3.15v ?5.0 v external power supply for i/o drivers. the 100-pin package features 3 i/o supply pins. vssx [3:1] 0v return ground for i/o drivers. the100-pin package provides 3 ground pins vddx 3.15v ?5.0 v external power supply for i/o drivers, all packages except 100-pin feature 1 i/o supply. vssx 0v return ground for i/o drivers. all packages except 100-pin provide 1 i/o ground pin. vdda 3.15v ?5.0 v external power supply for the analog-to-digital converter and for the reference circuit of the internal voltage regulator. vssa 0v return ground for vdda analog supply vddxr 3.15v ?5.0 v external power supply for i/o drivers and internal voltage regulator. for the 48-pin package the vddx and vddr supplies are combined on one pin. vddxra 3.15v ?5.0 v external power supply for i/o drivers, internal voltage regulator and analog-to-digital converter. for the 20- and 32-pin package the vddx, vddr and vdda supplies are combined on one pin. vssxa 0v return ground for i/o driver and vdda analog supply vrh 3.15v ?5.0 v reference voltage for the analog-to-digital converter.
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 62 freescale semiconductor 1.8 device pinouts 1.8.1 s12gn16 and s12gn32 1.8.1.1 pinout 20-pin tssop figure 1-3. 20-pin tssop pinout for s12gn16 and s12gn32 table 1-8. 20-pin tssop pinout for s12gn16 and s12gn32 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func 6th func 7th func 8th func ctrl reset state 1 ps6 ioc3 sck0 v ddx pers/ppss up 2 ps7 etrig3 api_extclk eclk pwm3 txd0 ss0 v ddx pers/ppss up 3 reset v ddx pullup 4 vddxra vrh 5 vssxa 6 pe0 1 etrig0 pwm0 ioc2 rxd0 extal v ddx pucr/pdpee down 7 vss 8 pe1 1 etrig1 pwm1 ioc3 txd0 xtal pucr/pdpee down 9 test n.a. reset pin down 10 bkgd modc v ddx always on up 11 pt1 ioc1 irq v ddx pert/ppst disabled 12 pt0 ioc0 xirq v ddx pert/ppst disabled 13 pad0 kwad0 an0 v dda per1ad/pps1ad disabled 14 pad1 kwad1 an1 v dda per1ad/pps1ad disabled 15 pad2 kwad2 an2 v dda per1ad/pps1ad disabled 1 2 3 4 5 6 7 8 9 10 20 19 18 17 16 15 14 13 12 11 s12gn16 s12gn32 20-pin tssop ps5/ioc2/mosi0 ps4/etrig2/pwm2/rxd0/miso0 pad5/kwad5/etrig3/pwm3/ioc3/txd0/an5/acmpm pad4/kwad4/etrig2/pwm2/ioc2/rxd0/an4/acmpp pad3/kwad3/an3/acmpo pad2/kwad2/an2 pad1/kwad1/an1 pad0/kwad0/an0 pt0/ioc0/ xirq pt1/ioc1/ irq sck0/ioc3/ps6 ss0/txd0/pwm3/eclk/api_extclk/etrig3/ps7 reset vrh/vddxra vssxa extal/rxd0/pwm0/ioc2/etrig0/pe0 vss xtal/txd0/pwm1/ioc3/etrig1/pe1 test bkgd
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 63 16 pad3 kwad3 an3 acmpo v dda per1ad/pps1ad disabled 17 pad4 kwad4 etrig2 pwm2 ioc2 rxd0 an4 acmpp v dda per1ad/pps1ad disabled 18 pad5 kwad5 etrig3 pwm3 ioc3 txd0 an5 acmpm v dda per1ad/pps1ad disabled 19 ps4 etrig2 pwm2 rxd0 miso0 v ddx pers/ppss up 20 ps5 ioc2 mosi0 v ddx pers/ppss up 1 the regular i/o characteristics (see section a.2, ?/o characteristics ) apply if the extal/xtal function is disabled table 1-8. 20-pin tssop pinout for s12gn16 and s12gn32 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func 6th func 7th func 8th func ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 64 freescale semiconductor 1.8.1.2 pinout 32-pin lqfp figure 1-4. 32-pin lqfp opinout for s12gn16 and s12gn32 table 1-9. 32-pin lqfp opinout for s12gn16 and s12gn32 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state 1 reset v ddx pullup 2 vddxra vrh 3 vssxa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 24 23 22 21 20 19 18 17 32 31 30 29 28 27 26 25 s12gn16 s12gn32 32-pin lqfp pad7/kwad7/an7/acmpm pad6/kwad6/an6/acmpp pad5/kwad5/an5/acmpo pad4/kwad4/an4 pad3/kwad3/an3 pad2/kwad2/an2 pad1/kwad1/an1 pad0/kwad0/an0 pwm0/api_extclk/etrig0/kwp0/pp0 pwm1/eclkx2/etrig1/kwp1/pp1 pwm2/etrig2/kwp2/pp2 pwm3/etrig3/kwp3/pp3 ioc3/pt3 ioc2/pt2 irq/ioc1/pt1 xirq/ioc0/pt0 reset vrh/vddxra vssxa extal/pe0 vss xtal/pe1 test bkgd pm1 pm0 ps7/api_extclk/eclk/pwm5/ ss 0 ps6/ioc5/sck0 ps5/ioc4/mosi0 ps4/pwm4/miso0 ps1/txd0 ps0/rxd0
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 65 4 pe0 1 extal pucr/pdpee down 5 vss 6 pe1 1 xtal pucr/pdpee down 7 test n.a. reset pin down 8 bkgd modc v ddx pucr/bkpue up 9 pp0 kwp0 etrig0 api_extclk pwm0 v ddx perp/ppsp disabled 10 pp1 kwp1 etrig1 eclkx2 pwm1 v ddx perp/ppsp disabled 11 pp2 kwp2 etrig2 pwm2 v ddx perp/ppsp disabled 12 pp3 kwp3 etrig3 pwm3 v ddx perp/ppsp disabled 13 pt3 ioc3 v ddx pert/ppst disabled 14 pt2 ioc2 v ddx pert/ppst disabled 15 pt1 ioc1 irq v ddx pert/ppst disabled 16 pt0 ioc0 xirq v ddx pert/ppst disabled 17 pad0 kwad0 an0 v dda per1ad/pps1ad disabled 18 pad1 kwad1 an1 v dda per1ad/pps1ad disabled 19 pad2 kwad2 an2 v dda per1ad/pps1ad disabled 20 pad3 kwad3 an3 v dda per1ad/pps1ad disabled 21 pad4 kwad4 an4 v dda per1ad/pps1ad disabled 22 pad5 kwad5 an5 acmpo v dda per1ad/pps1ad disabled 23 pad6 kwad6 an6 acmpp v dda per1ad/pps1ad disabled 24 pad7 kwad7 an7 acmpm v dda per1ad/pps1ad disabled 25 ps0 rxd0 v ddx pers/ppss up 26 ps1 txd0 v ddx pers/ppss up 27 ps4 pwm4 miso0 v ddx pers/ppss up 28 ps5 ioc4 mosi0 v ddx pers/ppss up 29 ps6 ioc5 sck0 v ddx pers/ppss up 30 ps7 api_extclk eclk pwm5 ss0 v ddx pers/ppss up 31 pm0 v ddx perm/ppsm disabled 32 pm1 v ddx perm/ppsm disabled table 1-9. 32-pin lqfp opinout for s12gn16 and s12gn32 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 66 freescale semiconductor 1.8.1.3 pinout 48-pin lqfp/qfn figure 1-5. 48-pin lqfp/qfn pinout for s12gn16 and s12gn32 1 the regular i/o characteristics (see section a.2, ?/o characteristics ) apply if the extal/xtal function is disabled 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 36 35 34 33 32 31 30 29 28 27 26 25 48 47 46 45 44 43 42 41 40 39 38 37 s12gn16 s12gn32 48-pin lqfp/qfn pad7/kwad7/an7 pad6/kwad6/an6 pad5/kwad5/an5 pad4/kwad4/an4 pad11/kwad11/acmpm pad3/kwad3/an3 pad10/kwad10/acmpp pad2/kwad2/an2 pad9/kwad9/acmpo pad1/kwad1/an1 pad8/kwad8 pad0/kwad0/an0 pwm0/api_extclk/etrig0/kwp0/pp0 pwm1/eclkx2/etrig1/kwp1/pp1 pwm2/etrig2/kwp2/pp2 pwm3/etrig3/kwp3/pp3 pwm4/kwp4/pp4 pwm5/kwp5/pp5 ioc5/pt5 ioc4/pt4 ioc3/pt3 ioc2/pt2 irq/ioc1/pt1 xirq/ioc0/pt0 reset vddxr vssx extal/pe0 vss xtal/pe1 test kwj0/pj0 kwj1/pj1 kwj2/pj2 kwj3/pj3 bkgd pm1 pm0 ps7/api_extclk/eclk/ ss0 ps6/sck0 ps5/mosi0 ps4/miso0 ps3 ps2 ps1/txd0 ps0/rxd0 vssa vdda/vrh
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 67 table 1-10. 48-pin lqfp/qfn pinout for s12gn16 and s12gn32 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state 1 reset v ddx pullup 2 vddxr 3 vssx 4 pe0 1 extal v ddx pucr/pdpee down 5 vss 6 pe1 1 xtal v ddx pucr/pdpee down 7 test n.a. reset pin down 8 pj0 kwj0 v ddx perj/ppsj up 9 pj1 kwj1 v ddx perj/ppsj up 10 pj2 kwj2 v ddx perj/ppsj up 11 pj3 kwj3 v ddx perj/ppsj up 12 bkgd modc v ddx pucr/bkpue up 13 pp0 kwp0 etrig0 api_extclk pwm0 v ddx perp/ppsp disabled 14 pp1 kwp1 etrig1 eclkx2 pwm1 v ddx perp/ppsp disabled 15 pp2 kwp2 etrig2 pwm2 v ddx perp/ppsp disabled 16 pp3 kwp3 etrig3 pwm3 v ddx perp/ppsp disabled 17 pp4 kwp4 pwm4 v ddx perp/ppsp disabled 18 pp5 kwp5 pwm5 v ddx perp/ppsp disabled 19 pt5 ioc5 v ddx pert/ppst disabled 20 pt4 ioc4 v ddx pert/ppst disabled 21 pt3 ioc3 v ddx pert/ppst disabled 22 pt2 ioc2 v ddx pert/ppst disabled 23 pt1 ioc1 irq v ddx pert/ppst disabled 24 pt0 ioc0 xirq v ddx pert/ppst disabled 25 pad0 kwad0 an0 v dda per1ad/pps1ad disabled 26 pad8 kwad8 v dda per0ad/pps0ad disabled 27 pad1 kwad1 an1 v dda per1ad/pps1ad disabled
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 68 freescale semiconductor 28 pad9 kwad9 acmpo v dda per0ad/pps0ad disabled 29 pad2 kwad2 an2 v dda per1ad/pps1ad disabled 30 pad10 kwad10 acmpp v dda per0ad/pps0ad disabled 31 pad3 kwad3 an3 v dda per1ad/pps1ad disabled 32 pad11 kwad11 acmpm v dda per0ad/pps0ad disabled 33 pad4 kwad4 an4 v dda per1ad/pps1ad disabled 34 pad5 kwad5 an5 v dda per1ad/pps0ad disabled 35 pad6 kwad6 an6 v dda per1ad/pps1ad disabled 36 pad7 kwad7 an7 v dda per1ad/pps1ad disabled 37 vdda vrh 38 vssa 39 ps0 rxd0 v ddx pers/ppss up 40 ps1 txd0 v ddx pers/ppss up 41 ps2 v ddx pers/ppss up 42 ps3 v ddx pers/ppss up 43 ps4 miso0 v ddx pers/ppss up 44 ps5 mosi0 v ddx pers/ppss up 45 ps6 sck0 v ddx pers/ppss up 46 ps7 api_extclk eclk ss0 v ddx pers/ppss up 47 pm0 v ddx perm/ppsm disabled 48 pm1 v ddx perm/ppsm disabled 1 the regular i/o characteristics (see section a.2, ?/o characteristics ) apply if the extal/xtal function is disabled table 1-10. 48-pin lqfp/qfn pinout for s12gn16 and s12gn32 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 69 1.8.2 s12gna16 and s12gna32 1.8.2.1 pinout 48-pin lqfp/qfn figure 1-6. 48-pin lqfp/qfn pinout for s12gna16 and s12gna32 table 1-11. 48-pin lqfp/qfn pinout for s12gna16 and s12gna32 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state 1 reset v ddx pullup 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 36 35 34 33 32 31 30 29 28 27 26 25 48 47 46 45 44 43 42 41 40 39 38 37 s12gna16 s12gna32 48-pin lqfp/qfn pad7/kwad7/an7 pad6/kwad6/an6 pad5/kwad5/an5 pad4/kwad4/an4 pad11/kwad11/acmpm pad3/kwad3/an3 pad10/kwad10/acmpp pad2/kwad2/an2 pad9/kwad9/acmpo pad1/kwad1/an1 pad8/kwad8 pad0/kwad0/an0 pwm0/api_extclk/etrig0/kwp0/pp0 pwm1/eclkx2/etrig1/kwp1/pp1 pwm2/etrig2/kwp2/pp2 pwm3/etrig3/kwp3/pp3 pwm4/kwp4/pp4 pwm5/kwp5/pp5 ioc5/pt5 ioc4/pt4 ioc3/pt3 ioc2/pt2 irq/ioc1/pt1 xirq/ioc0/pt0 reset vddxr vssx extal/pe0 vss xtal/pe1 test kwj0/pj0 kwj1/pj1 kwj2/pj2 kwj3/pj3 bkgd pm1 pm0 ps7/api_extclk/eclk/ ss0 ps6/sck0 ps5/mosi0 ps4/miso0 ps3 ps2 ps1/txd0 ps0/rxd0 vssa vdda/vrh
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 70 freescale semiconductor 2 vddxr 3 vssx 4 pe0 1 extal v ddx pucr/pdpee down 5 vss 6 pe1 1 xtal v ddx pucr/pdpee down 7 test n.a. reset pin down 8 pj0 kwj0 v ddx perj/ppsj up 9 pj1 kwj1 v ddx perj/ppsj up 10 pj2 kwj2 v ddx perj/ppsj up 11 pj3 kwj3 v ddx perj/ppsj up 12 bkgd modc v ddx pucr/bkpue up 13 pp0 kwp0 etrig0 api_extclk pwm0 v ddx perp/ppsp disabled 14 pp1 kwp1 etrig1 eclkx2 pwm1 v ddx perp/ppsp disabled 15 pp2 kwp2 etrig2 pwm2 v ddx perp/ppsp disabled 16 pp3 kwp3 etrig3 pwm3 v ddx perp/ppsp disabled 17 pp4 kwp4 pwm4 v ddx perp/ppsp disabled 18 pp5 kwp5 pwm5 v ddx perp/ppsp disabled 19 pt5 ioc5 v ddx pert/ppst disabled 20 pt4 ioc4 v ddx pert/ppst disabled 21 pt3 ioc3 v ddx pert/ppst disabled 22 pt2 ioc2 v ddx pert/ppst disabled 23 pt1 ioc1 irq v ddx pert/ppst disabled 24 pt0 ioc0 xirq v ddx pert/ppst disabled 25 pad0 kwad0 an0 v dda per1ad/pps1ad disabled 26 pad8 kwad8 v dda per0ad/pps0ad disabled 27 pad1 kwad1 an1 v dda per1ad/pps1ad disabled 28 pad9 kwad9 acmpo v dda per0ad/pps0ad disabled 29 pad2 kwad2 an2 v dda per1ad/pps1ad disabled 30 pad10 kwad10 acmpp v dda per0ad/pps0ad disabled table 1-11. 48-pin lqfp/qfn pinout for s12gna16 and s12gna32 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 71 1.8.3 s12gn48 1.8.3.1 pinout 32-pin lqfp 31 pad3 kwad3 an3 v dda per1ad/pps1ad disabled 32 pad11 kwad11 acmpm v dda per0ad/pps0ad disabled 33 pad4 kwad4 an4 v dda per1ad/pps1ad disabled 34 pad5 kwad5 an5 v dda per1ad/pps0ad disabled 35 pad6 kwad6 an6 v dda per1ad/pps1ad disabled 36 pad7 kwad7 an7 v dda per1ad/pps1ad disabled 37 vdda vrh 38 vssa 39 ps0 rxd0 v ddx pers/ppss up 40 ps1 txd0 v ddx pers/ppss up 41 ps2 v ddx pers/ppss up 42 ps3 v ddx pers/ppss up 43 ps4 miso0 v ddx pers/ppss up 44 ps5 mosi0 v ddx pers/ppss up 45 ps6 sck0 v ddx pers/ppss up 46 ps7 api_extclk eclk ss0 v ddx pers/ppss up 47 pm0 v ddx perm/ppsm disabled 48 pm1 v ddx perm/ppsm disabled 1 the regular i/o characteristics (see section a.2, ?/o characteristics ) apply if the extal/xtal function is disabled table 1-11. 48-pin lqfp/qfn pinout for s12gna16 and s12gna32 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 72 freescale semiconductor figure 1-7. 32-pin lqfp pinout for s12gn48 table 1-12. 32-pin lqfp pinout for s12gn48 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state 1 reset v ddx pullup 2 vddxra vrh 3 vssxa 4 pe0 1 extal pucr/pdpee down 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 24 23 22 21 20 19 18 17 32 31 30 29 28 27 26 25 s12gn48 32-pin lqfp pad7/kwad7/an7/acmpm pad6/kwad6/an6/acmpp pad5/kwad5/an5/acmpo pad4/kwad4/an4 pad3/kwad3/an3 pad2/kwad2/an2 pad1/kwad1/an1 pad0/kwad0/an0 pwm0/api_extclk/etrig0/kwp0/pp0 pwm1/eclkx2/etrig1/kwp1/pp1 pwm2/etrig2/kwp2/pp2 pwm3/etrig3/kwp3/pp3 ioc3/pt3 ioc2/pt2 irq/ioc1/pt1 xirq/ioc0/pt0 reset vrh/vddxra vssxa extal/pe0 vss xtal/pe1 test bkgd pm1/txd1 pm0/rxd1 ps7/api_extclk/eclk/pwm5/ ss0 ps6/ioc5/sck0 ps5/ioc4/mosi0 ps4/pwm4/miso0 ps1/txd0 ps0/rxd0
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 73 5 vss 6 pe1 1 xtal pucr/pdpee down 7 test n.a. reset pin down 8 bkgd modc v ddx pucr/bkpue up 9 pp0 kwp0 etrig0 api_extclk pwm0 v ddx perp/ppsp disabled 10 pp1 kwp1 etrig1 eclkx2 pwm1 v ddx perp/ppsp disabled 11 pp2 kwp2 etrig2 pwm2 v ddx perp/ppsp disabled 12 pp3 kwp3 etrig3 pwm3 v ddx perp/ppsp disabled 13 pt3 ioc3 v ddx pert/ppst disabled 14 pt2 ioc2 v ddx pert/ppst disabled 15 pt1 ioc1 irq v ddx pert/ppst disabled 16 pt0 ioc0 xirq v ddx pert/ppst disabled 17 pad0 kwad0 an0 v dda per1ad/pps1ad disabled 18 pad1 kwad1 an1 v dda per1ad/pps1ad disabled 19 pad2 kwad2 an2 v dda per1ad/pps1ad disabled 20 pad3 kwad3 an3 v dda per1ad/pps1ad disabled 21 pad4 kwad4 an4 v dda per1ad/pps1ad disabled 22 pad5 kwad5 an5 acmpo v dda per1ad/pps1ad disabled 23 pad6 kwad6 an6 acmpp v dda per1ad/pps1ad disabled 24 pad7 kwad7 an7 acmpm v dda per1ad/pps1ad disabled 25 ps0 rxd0 v ddx pers/ppss up 26 ps1 txd0 v ddx pers/ppss up 27 ps4 pwm4 miso0 v ddx pers/ppss up 28 ps5 ioc4 mosi0 v ddx pers/ppss up 29 ps6 ioc5 sck0 v ddx pers/ppss up 30 ps7 api_extclk eclk pwm5 ss0 v ddx pers/ppss up 31 pm0 rxd1 v ddx perm/ppsm disabled 32 pm1 txd1 v ddx perm/ppsm disabled 1 the regular i/o characteristics (see section a.2, ?/o characteristics ) apply if the extal/xtal function is disabled table 1-12. 32-pin lqfp pinout for s12gn48 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 74 freescale semiconductor 1.8.3.2 pinout 48-pin lqfp figure 1-8. 48-pin lqfp pinout for s12gn48 table 1-13. 48-pin lqfp pinout for s12gn48 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state 1 reset v ddx pullup 2 vddxr 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 36 35 34 33 32 31 30 29 28 27 26 25 48 47 46 45 44 43 42 41 40 39 38 37 s12gn48 48-pin lqfp pad7/kwad7/an7 pad6/kwad6/an6 pad5/kwad5/an5 pad4/kwad4/an4 pad11/kwad11/an11/acmpm pad3/kwad3/an3 pad10/kwad10/an10/acmpp pad2/kwad2/an2 pad9/kwad9/an9/acmpo pad1/kwad1/an1 pad8/kwad8/an8 pad0/kwad0/an0 pwm0/api_extclk/etrig0/kwp0/pp0 pwm1/eclkx2/etrig1/kwp1/pp1 pwm2/etrig2/kwp2/pp2 pwm3/etrig3/kwp3/pp3 pwm4/kwp4/pp4 pwm5/kwp5/pp5 ioc5/pt5 ioc4/pt4 ioc3/pt3 ioc2/pt2 irq/ioc1/pt1 xirq/ioc0/pt0 reset vddxr vssx extal/pe0 vss xtal/pe1 test miso1/kwj0/pj0 mosi1/kwj1/pj1 sck1/kwj2/pj2 ss1/kwj3/pj3 bkgd pm1 pm0 ps7/api_extclk/eclk/ ss0 ps6/sck0 ps5/mosi0 ps4/miso0 ps3/txd1 ps2/rxd1 ps1/txd0 ps0/rxd0 vssa vdda/vrh
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 75 3 vssx 4 pe0 1 extal v ddx pucr/pdpee down 5 vss 6 pe1 1 xtal v ddx pucr/pdpee down 7 test n.a. reset pin down 8 pj0 kwj0 miso1 v ddx perj/ppsj up 9 pj1 kwj1 mosi1 v ddx perj/ppsj up 10 pj2 kwj2 sck1 v ddx perj/ppsj up 11 pj3 kwj3 ss1 v ddx perj/ppsj up 12 bkgd modc v ddx pucr/bkpue up 13 pp0 kwp0 etrig0 api_extclk pwm0 v ddx perp/ppsp disabled 14 pp1 kwp1 etrig1 eclkx2 pwm1 v ddx perp/ppsp disabled 15 pp2 kwp2 etrig2 pwm2 v ddx perp/ppsp disabled 16 pp3 kwp3 etrig3 pwm3 v ddx perp/ppsp disabled 17 pp4 kwp4 pwm4 v ddx perp/ppsp disabled 18 pp5 kwp5 pwm5 v ddx perp/ppsp disabled 19 pt5 ioc5 v ddx pert/ppst disabled 20 pt4 ioc4 v ddx pert/ppst disabled 21 pt3 ioc3 v ddx pert/ppst disabled 22 pt2 ioc2 v ddx pert/ppst disabled 23 pt1 ioc1 irq v ddx pert/ppst disabled 24 pt0 ioc0 xirq v ddx pert/ppst disabled 25 pad0 kwad0 an0 v dda per1ad/pps1ad disabled 26 pad8 kwad8 an8 v dda per0ad/pps0ad disabled 27 pad1 kwad1 an1 v dda per1ad/pps1ad disabled 28 pad9 kwad9 an9 acmpo v dda per0ad/pps0ad disabled 29 pad2 kwad2 an2 v dda per1ad/pps1ad disabled 30 pad10 kwad10 an10 acmpp v dda per0ad/pps0ad disabled 31 pad3 kwad3 an3 v dda per1ad/pps1ad disabled table 1-13. 48-pin lqfp pinout for s12gn48 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 76 freescale semiconductor 32 pad11 kwad11 an11 acmpm v dda per0ad/pps0ad disabled 33 pad4 kwad4 an4 v dda per1ad/pps1ad disabled 34 pad5 kwad5 an5 v dda per1ad/pps0ad disabled 35 pad6 kwad6 an6 v dda per1ad/pps1ad disabled 36 pad7 kwad7 an7 v dda per1ad/pps1ad disabled 37 vdda vrh 38 vssa 39 ps0 rxd0 v ddx pers/ppss up 40 ps1 txd0 v ddx pers/ppss up 41 ps2 rxd1 v ddx pers/ppss up 42 ps3 txd1 v ddx pers/ppss up 43 ps4 miso0 v ddx pers/ppss up 44 ps5 mosi0 v ddx pers/ppss up 45 ps6 sck0 v ddx pers/ppss up 46 ps7 api_extclk eclk ss0 v ddx pers/ppss up 47 pm0 v ddx perm/ppsm disabled 48 pm1 v ddx perm/ppsm disabled 1 the regular i/o characteristics (see section a.2, ?/o characteristics ) apply if the extal/xtal function is disabled table 1-13. 48-pin lqfp pinout for s12gn48 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 77 1.8.3.3 pinout 64-pin lqfp figure 1-9. 64-pin lqfp pinout for s12gn48 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 s12gn48 64-pin lqfp pwm0/api_extclk/etrig0/kwp0/pp0 pwm1/eclkx2/etrig1/kwp1/pp1 pwm2/etrig2/kwp2/pp2 pwm3/etrig3/kwp3/pp3 pwm4/kwp4/pp4 pwm5/kwp5/pp5 kwp6/pp6 kwp7/pp7 pt7 pt6 ioc5/pt5 ioc4/pt4 ioc3/pt3 ioc2/pt2 irq/ioc1/pt1 xirq/ioc0/pt0 kwj6/pj6 kwj5/pj5 kwj4/pj4 reset vddx vddr vssx extal/pe0 vss xtal/pe1 test miso1/kwj0/pj0 mosi1/kwj1/pj1 sck1/kwj2/pj2 ss1/kwj3/pj3 bkgd pj7/kwj7 pm3 pm2 pm1 pm0 ps7/api_extclk/eclk/ ss0 ps6/sck0 ps5/mosi0 ps4/miso0 ps3/txd1 ps2/rxd1 ps1/txd0 ps0/rxd0 vssa vdda vrh pad15/kwad15 pad7/kwad7/an7 pad14/kwad14 pad6/kwad6/an6 pad13/kwad13 pad5/kwad5/an5 pad12/kwad12 pad4/kwad4/an4 pad11/kwad11/an11/acmpm pad3/kwad3/an3 pad10/kwad10/an10/acmpp pad2/kwad2/an2 pad9/kwad9/an9/acmpo pad1/kwad1/an1 pad8/kwad8/an8 pad0/kwad0/an0
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 78 freescale semiconductor table 1-14. 64-pin lqfp pinout for s12gn48 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state 1 pj6 kwj6 v ddx perj/ppsj up 2 pj5 kwj5 v ddx perj/ppsj up 3 pj4 kwj4 v ddx perj/ppsj up 4 reset v ddx pullup 5 vddx 6 vddr 7 vssx 8 pe0 1 extal v ddx pucr/pdpee down 9 vss 10 pe1 1 xtal v ddx pucr/pdpee down 11 test n.a. reset pin down 12 pj0 kwj0 miso1 v ddx perj/ppsj up 13 pj1 kwj1 mosi1 v ddx perj/ppsj up 14 pj2 kwj2 sck1 v ddx perj/ppsj up 15 pj3 kwj3 ss1 v ddx perj/ppsj up 16 bkgd modc v ddx pucr/bkpue up 17 pp0 kwp0 etrig0 api_extclk pwm0 v ddx perp/ppsp disabled 18 pp1 kwp1 etrig1 eclkx2 pwm1 v ddx perp/ppsp disabled 19 pp2 kwp2 etrig2 pwm2 v ddx perp/ppsp disabled 20 pp3 kwp3 etrig3 pwm3 v ddx perp/ppsp disabled 21 pp4 kwp4 pwm4 v ddx perp/ppsp disabled 22 pp5 kwp5 pwm5 v ddx perp/ppsp disabled 23 pp6 kwp6 v ddx perp/ppsp disabled 24 pp7 kwp7 v ddx perp/ppsp disabled 25 pt7 v ddx pert/ppst disabled 26 pt6 v ddx pert/ppst disabled 27 pt5 ioc5 v ddx pert/ppst disabled
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 79 28 pt4 ioc4 v ddx pert/ppst disabled 29 pt3 ioc3 v ddx pert/ppst disabled 30 pt2 ioc2 v ddx pert/ppst disabled 31 pt1 ioc1 irq v ddx pert/ppst disabled 32 pt0 ioc0 xirq v ddx pert/ppst disabled 33 pad0 kwad0 an0 v dda per1ad/pps1ad disabled 34 pad8 kwad8 an8 v dda per0ad/pps0ad disabled 35 pad1 kwad1 an1 v dda per1ad/pps1ad disabled 36 pad9 kwad9 an9 acmpo v dda per0adpps0ad disabled 37 pad2 kwad2 an2 v dda per1ad/pps1ad disabled 38 pad10 kwad10 an10 acmpp v dda per0ad/pps0ad disabled 39 pad3 kwad3 an3 v dda per1ad/pps1ad disabled 40 pad11 kwad11 an11 acmpm v dda per0ad/pps0ad disabled 41 pad4 kwad4 an4 v dda per1ad/pps1ad disabled 42 pad12 kwad12 v dda per0ad/pps0ad disabled 43 pad5 kwad5 an5 v dda per1ad/pps1ad disabled 44 pad13 kwad13 v dda per0ad/pps0ad disabled 45 pad6 kwad6 an6 v dda per1ad/pps1ad disabled 46 pad14 kwad14 v dda per0ad/pps0ad disabled 47 pad7 kwad7 an7 v dda per1ad/pps1ad disabled 48 pad15 kwad15 v dda per0ad/pps0ad disabled 49 vrh 50 vdda 51 vssa 52 ps0 rxd0 v ddx pers/ppss up 53 ps1 txd0 v ddx pers/ppss up 54 ps2 rxd1 v ddx pers/ppss up 55 ps3 txd1 v ddx pers/ppss up 56 ps4 miso0 v ddx pers/ppss up table 1-14. 64-pin lqfp pinout for s12gn48 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 80 freescale semiconductor 57 ps5 mosi0 v ddx pers/ppss up 58 ps6 sck0 v ddx pers/ppss up 59 ps7 api_extclk eclk ss0 v ddx pers/ppss up 60 pm0 v ddx perm/ppsm disabled 61 pm1 v ddx perm/ppsm disabled 62 pm2 v ddx perm/ppsm disabled 63 pm3 v ddx perm/ppsm disabled 64 pj7 kwj7 v ddx perj/ppsj up 1 the regular i/o characteristics (see section a.2, ?/o characteristics ) apply if the extal/xtal function is disabled table 1-14. 64-pin lqfp pinout for s12gn48 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 81 1.8.4 s12g48 and s12g64 1.8.4.1 pinout 32-pin lqfp figure 1-10. 32-pin lqfp pinout for s12g48 and s12g64 table 1-15. 32-pin lqfp pinout for s12g48 and s12g64 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state 1 reset v ddx pullup 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 24 23 22 21 20 19 18 17 32 31 30 29 28 27 26 25 s12g48 s12g64 32-pin lqfp pad7/kwad7/an7/acmpm pad6/kwad6/an6/acmpp pad5/kwad5/an5/acmpo pad4/kwad4/an4 pad3/kwad3/an3 pad2/kwad2/an2 pad1/kwad1/an1 pad0/kwad0/an0 pwm0/api_extclk/etrig0/kwp0/pp0 pwm1/eclkx2/etrig1/kwp1/pp1 pwm2/etrig2/kwp2/pp2 pwm3/etrig3/kwp3/pp3 ioc3/pt3 ioc2/pt2 irq/ioc1/pt1 xirq/ioc0/pt0 reset vrh/vddxra vssxa extal/pe0 vss xtal/pe1 test bkgd pm1/txd1/txcan pm0/rxd1/rxcan ps7/api_extclk/eclk/pwm5/ ss0 ps6/ioc5/sck0 ps5/ioc4/mosi0 ps4/pwm4/miso0 ps1/txd0 ps0/rxd0
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 82 freescale semiconductor 2 vddxra vrh 3 vssxa 4 pe0 1 extal pucr/pdpee down 5 vss 6 pe1 1 xtal pucr/pdpee down 7 test n.a. reset pin down 8 bkgd modc v ddx pucr/bkpue up 9 pp0 kwp0 etrig0 api_extclk pwm0 v ddx perp/ppsp disabled 10 pp1 kwp1 etrig1 eclkx2 pwm1 v ddx perp/ppsp disabled 11 pp2 kwp2 etrig2 pwm2 v ddx perp/ppsp disabled 12 pp3 kwp3 etrig3 pwm3 v ddx perp/ppsp disabled 13 pt3 ioc3 v ddx pert/ppst disabled 14 pt2 ioc2 v ddx pert/ppst disabled 15 pt1 ioc1 irq v ddx pert/ppst disabled 16 pt0 ioc0 xirq v ddx pert/ppst disabled 17 pad0 kwad0 an0 v dda per1ad/pps1ad disabled 18 pad1 kwad1 an1 v dda per1ad/pps1ad disabled 19 pad2 kwad2 an2 v dda per1ad/pps1ad disabled 20 pad3 kwad3 an3 v dda per1ad/pps1ad disabled 21 pad4 kwad4 an4 v dda per1ad/pps1ad disabled 22 pad5 kwad5 an5 acmpo v dda per1ad/pps1ad disabled 23 pad6 kwad6 an6 acmpp v dda per1ad/pps1ad disabled 24 pad7 kwad7 an7 acmpm v dda per1ad/pps1ad disabled 25 ps0 rxd0 v ddx pers/ppss up 26 ps1 txd0 v ddx pers/ppss up 27 ps4 pwm4 miso0 v ddx pers/ppss up 28 ps5 ioc4 mosi0 v ddx pers/ppss up 29 ps6 ioc5 sck0 v ddx pers/ppss up 30 ps7 api_extclk eclk pwm5 ss0 v ddx pers/ppss up table 1-15. 32-pin lqfp pinout for s12g48 and s12g64 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 83 1.8.4.2 pinout 48-pin lqfp figure 1-11. 48-pin lqfp pinout for s12g48 and s12g64 31 pm0 rxd1 rxcan v ddx perm/ppsm disabled 32 pm1 txd1 txcan v ddx perm/ppsm disabled 1 the regular i/o characteristics (see section a.2, ?/o characteristics ) apply if the extal/xtal function is disabled table 1-15. 32-pin lqfp pinout for s12g48 and s12g64 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 36 35 34 33 32 31 30 29 28 27 26 25 48 47 46 45 44 43 42 41 40 39 38 37 s12g48 s12g64 48-pin lqfp pad7/kwad7/an7 pad6/kwad6/an6 pad5/kwad5/an5 pad4/kwad4/an4 pad11/kwad11/an11/acmpm pad3/kwad3/an3 pad10/kwad10/an10/acmpp pad2/kwad2/an2 pad9/kwad9/an9/acmpo pad1/kwad1/an1 pad8/kwad8/an8 pad0/kwad0/an0 pwm0/api_extclk/etrig0/kwp0/pp0 pwm1/eclkx2/etrig1/kwp1/pp1 pwm2/etrig2/kwp2/pp2 pwm3/etrig3/kwp3/pp3 pwm4/kwp4/pp4 pwm5/kwp5/pp5 ioc5/pt5 ioc4/pt4 ioc3/pt3 ioc2/pt2 irq/ioc1/pt1 xirq/ioc0/pt0 reset vddxr vssx extal/pe0 vss xtal/pe1 test miso1/kwj0/pj0 mosi1/kwj1/pj1 sck1/kwj2/pj2 ss1/kwj3/pj3 bkgd pm1/txcan pm0/rxcan ps7/api_extclk/eclk/ ss0 ps6/sck0 ps5/mosi0 ps4/miso0 ps3/txd1 ps2/rxd1 ps1/txd0 ps0/rxd0 vssa vdda/vrh
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 84 freescale semiconductor table 1-16. 48-pin lqfp pinout for s12g48 and s12g64 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state 1 reset v ddx pullup 2 vddxr 3 vssx 4 pe0 1 extal v ddx pucr/pdpee down 5 vss 6 pe1 1 xtal v ddx pucr/pdpee down 7 test n.a. reset pin down 8 pj0 kwj0 miso1 v ddx perj/ppsj up 9 pj1 kwj1 mosi1 v ddx perj/ppsj up 10 pj2 kwj2 sck1 v ddx perj/ppsj up 11 pj3 kwj3 ss1 v ddx perj/ppsj up 12 bkgd modc v ddx pucr/bkpue up 13 pp0 kwp0 etrig0 api_extclk pwm0 v ddx perp/ppsp disabled 14 pp1 kwp1 etrig1 eclkx2 pwm1 v ddx perp/ppsp disabled 15 pp2 kwp2 etrig2 pwm2 v ddx perp/ppsp disabled 16 pp3 kwp3 etrig3 pwm3 v ddx perp/ppsp disabled 17 pp4 kwp4 pwm4 v ddx perp/ppsp disabled 18 pp5 kwp5 pwm5 v ddx perp/ppsp disabled 19 pt5 ioc5 v ddx pert/ppst disabled 20 pt4 ioc4 v ddx pert/ppst disabled 21 pt3 ioc3 v ddx pert/ppst disabled 22 pt2 ioc2 v ddx pert/ppst disabled 23 pt1 ioc1 irq v ddx pert/ppst disabled 24 pt0 ioc0 xirq v ddx pert/ppst disabled 25 pad0 kwad0 an0 v dda per1ad/pps1ad disabled 26 pad8 kwad8 an8 v dda per0ad/pps0ad disabled 27 pad1 kwad1 an1 v dda per1ad/pps1ad disabled
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 85 28 pad9 kwad9 an9 acmpo v dda per0ad/pps0ad disabled 29 pad2 kwad2 an2 v dda per1ad/pps1ad disabled 30 pad10 kwad10 an10 acmpp v dda per0ad/pps0ad disabled 31 pad3 kwad3 an3 v dda per1ad/pps1ad disabled 32 pad11 kwad11 an11 acmpm v dda per0ad/pps0ad disabled 33 pad4 kwad4 an4 v dda per1ad/pps1ad disabled 34 pad5 kwad5 an5 v dda per1ad/pps0ad disabled 35 pad6 kwad6 an6 v dda per1ad/pps1ad disabled 36 pad7 kwad7 an7 v dda per1ad/pps1ad disabled 37 vdda vrh 38 vssa 39 ps0 rxd0 v ddx pers/ppss up 40 ps1 txd0 v ddx pers/ppss up 41 ps2 rxd1 v ddx pers/ppss up 42 ps3 txd1 v ddx pers/ppss up 43 ps4 miso0 v ddx pers/ppss up 44 ps5 mosi0 v ddx pers/ppss up 45 ps6 sck0 v ddx pers/ppss up 46 ps7 api_extclk eclk ss0 v ddx pers/ppss up 47 pm0 rxcan v ddx perm/ppsm disabled 48 pm1 txcan v ddx perm/ppsm disabled 1 the regular i/o characteristics (see section a.2, ?/o characteristics ) apply if the extal/xtal function is disabled table 1-16. 48-pin lqfp pinout for s12g48 and s12g64 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 86 freescale semiconductor 1.8.4.3 pinout 64-pin lqfp figure 1-12. 64-pin lqfp pinout for s12g48 and s12g64 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 s12g48 s12g64 64-pin lqfp pwm0/api_extclk/etrig0/kwp0/pp0 pwm1/eclkx2/etrig1/kwp1/pp1 pwm2/etrig2/kwp2/pp2 pwm3/etrig3/kwp3/pp3 pwm4/kwp4/pp4 pwm5/kwp5/pp5 kwp6/pp6 kwp7/pp7 pt7 pt6 ioc5/pt5 ioc4/pt4 ioc3/pt3 ioc2/pt2 irq/ioc1/pt1 xirq/ioc0/pt0 kwj6/pj6 kwj5/pj5 kwj4/pj4 reset vddx vddr vssx extal/pe0 vss xtal/pe1 test miso1/kwj0/pj0 mosi1/kwj1/pj1 sck1/kwj2/pj2 ss1/kwj3/pj3 bkgd pj7/kwj7 pm3 pm2 pm1/txcan pm0/rxcan ps7/api_extclk/eclk/ ss0 ps6/sck0 ps5/mosi0 ps4/miso0 ps3/txd1 ps2/rxd1 ps1/txd0 ps0/rxd0 vssa vdda vrh pad15/kwad15 pad7/kwad7/an7 pad14/kwad14 pad6/kwad6/an6 pad13/kwad13 pad5/kwad5/an5 pad12/kwad12 pad4/kwad4/an4 pad11/kwad11/an11/acmpm pad3/kwad3/an3 pad10/kwad10/an10/acmpp pad2/kwad2/an2 pad9/kwad9/an9/acmpo pad1/kwad1/an1 pad8/kwad8/an8 pad0/kwad0/an0
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 87 table 1-17. 64-pin lqfp pinout for s12g48 and s12g64 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state 1 pj6 kwj6 v ddx perj/ppsj up 2 pj5 kwj5 v ddx perj/ppsj up 3 pj4 kwj4 v ddx perj/ppsj up 4 reset v ddx pullup 5 vddx 6 vddr 7 vssx 8 pe0 1 extal v ddx pucr/pdpee down 9 vss 10 pe1 1 xtal v ddx pucr/pdpee down 11 test n.a. reset pin down 12 pj0 kwj0 miso1 v ddx perj/ppsj up 13 pj1 kwj1 mosi1 v ddx perj/ppsj up 14 pj2 kwj2 sck1 v ddx perj/ppsj up 15 pj3 kwj3 ss1 v ddx perj/ppsj up 16 bkgd modc v ddx pucr/bkpue up 17 pp0 kwp0 etrig0 api_extclk pwm0 v ddx perp/ppsp disabled 18 pp1 kwp1 etrig1 eclkx2 pwm1 v ddx perp/ppsp disabled 19 pp2 kwp2 etrig2 pwm2 v ddx perp/ppsp disabled 20 pp3 kwp3 etrig3 pwm3 v ddx perp/ppsp disabled 21 pp4 kwp4 pwm4 v ddx perp/ppsp disabled 22 pp5 kwp5 pwm5 v ddx perp/ppsp disabled 23 pp6 kwp6 v ddx perp/ppsp disabled 24 pp7 kwp7 v ddx perp/ppsp disabled 25 pt7 v ddx pert/ppst disabled 26 pt6 v ddx pert/ppst disabled 27 pt5 ioc5 v ddx pert/ppst disabled
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 88 freescale semiconductor 28 pt4 ioc4 v ddx pert/ppst disabled 29 pt3 ioc3 v ddx pert/ppst disabled 30 pt2 ioc2 v ddx pert/ppst disabled 31 pt1 ioc1 irq v ddx pert/ppst disabled 32 pt0 ioc0 xirq v ddx pert/ppst disabled 33 pad0 kwad0 an0 v dda per1ad/pps1ad disabled 34 pad8 kwad8 an8 v dda per0ad/pps0ad disabled 35 pad1 kwad1 an1 v dda per1ad/pps1ad disabled 36 pad9 kwad9 an9 acmpo v dda per0adpps0ad disabled 37 pad2 kwad2 an2 v dda per1ad/pps1ad disabled 38 pad10 kwad10 an10 acmpp v dda per0ad/pps0ad disabled 39 pad3 kwad3 an3 v dda per1ad/pps1ad disabled 40 pad11 kwad11 an11 acmpm v dda per0ad/pps0ad disabled 41 pad4 kwad4 an4 v dda per1ad/pps1ad disabled 42 pad12 kwad12 v dda per0ad/pps0ad disabled 43 pad5 kwad5 an5 v dda per1ad/pps1ad disabled 44 pad13 kwad13 v dda per0ad/pps0ad disabled 45 pad6 kwad6 an6 v dda per1ad/pps1ad disabled 46 pad14 kwad14 v dda per0ad/pps0ad disabled 47 pad7 kwad7 an7 v dda per1ad/pps1ad disabled 48 pad15 kwad15 v dda per0ad/pps0ad disabled 49 vrh 50 vdda 51 vssa 52 ps0 rxd0 v ddx pers/ppss up 53 ps1 txd0 v ddx pers/ppss up 54 ps2 rxd1 v ddx pers/ppss up 55 ps3 txd1 v ddx pers/ppss up 56 ps4 miso0 v ddx pers/ppss up table 1-17. 64-pin lqfp pinout for s12g48 and s12g64 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 89 57 ps5 mosi0 v ddx pers/ppss up 58 ps6 sck0 v ddx pers/ppss up 59 ps7 api_extclk eclk ss0 v ddx pers/ppss up 60 pm0 rxcan v ddx perm/ppsm disabled 61 pm1 txcan v ddx perm/ppsm disabled 62 pm2 v ddx perm/ppsm disabled 63 pm3 v ddx perm/ppsm disabled 64 pj7 kwj7 v ddx perj/ppsj up 1 the regular i/o characteristics (see section a.2, ?/o characteristics ) apply if the extal/xtal function is disabled table 1-17. 64-pin lqfp pinout for s12g48 and s12g64 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 90 freescale semiconductor 1.8.5 s12ga48 and s12ga64 1.8.5.1 pinout 48-pin lqfp figure 1-13. 48-pin lqfp pinout for s12ga48 and s12ga64 table 1-18. 48-pin lqfp pinout for s12ga48 and s12ga64 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state 1 reset v ddx pullup 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 36 35 34 33 32 31 30 29 28 27 26 25 48 47 46 45 44 43 42 41 40 39 38 37 s12ga48 s12ga64 48-pin lqfp pad7/kwad7/an7 pad6/kwad6/an6 pad5/kwad5/an5 pad4/kwad4/an4 pad11/kwad11/an11/acmpm pad3/kwad3/an3 pad10/kwad10/an10/acmpp pad2/kwad2/an2 pad9/kwad9/an9/acmpo pad1/kwad1/an1 pad8/kwad8/an8 pad0/kwad0/an0 pwm0/api_extclk/etrig0/kwp0/pp0 pwm1/eclkx2/etrig1/kwp1/pp1 pwm2/etrig2/kwp2/pp2 pwm3/etrig3/kwp3/pp3 pwm4/kwp4/pp4 pwm5/kwp5/pp5 ioc5/pt5 ioc4/pt4 ioc3/pt3 ioc2/pt2 irq/ioc1/pt1 xirq/ioc0/pt0 reset vddxr vssx extal/pe0 vss xtal/pe1 test miso1/kwj0/pj0 mosi1/kwj1/pj1 sck1/kwj2/pj2 ss1/kwj3/pj3 bkgd pm1/txcan pm0/rxcan ps7/api_extclk/eclk/ ss0 ps6/sck0 ps5/mosi0 ps4/miso0 ps3/txd1 ps2/rxd1 ps1/txd0 ps0/rxd0 vssa vdda/vrh
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 91 2 vddxr 3 vssx 4 pe0 1 extal v ddx pucr/pdpee down 5 vss 6 pe1 1 xtal v ddx pucr/pdpee down 7 test n.a. reset pin down 8 pj0 kwj0 miso1 v ddx perj/ppsj up 9 pj1 kwj1 mosi1 v ddx perj/ppsj up 10 pj2 kwj2 sck1 v ddx perj/ppsj up 11 pj3 kwj3 ss1 v ddx perj/ppsj up 12 bkgd modc v ddx pucr/bkpue up 13 pp0 kwp0 etrig0 api_extclk pwm0 v ddx perp/ppsp disabled 14 pp1 kwp1 etrig1 eclkx2 pwm1 v ddx perp/ppsp disabled 15 pp2 kwp2 etrig2 pwm2 v ddx perp/ppsp disabled 16 pp3 kwp3 etrig3 pwm3 v ddx perp/ppsp disabled 17 pp4 kwp4 pwm4 v ddx perp/ppsp disabled 18 pp5 kwp5 pwm5 v ddx perp/ppsp disabled 19 pt5 ioc5 v ddx pert/ppst disabled 20 pt4 ioc4 v ddx pert/ppst disabled 21 pt3 ioc3 v ddx pert/ppst disabled 22 pt2 ioc2 v ddx pert/ppst disabled 23 pt1 ioc1 irq v ddx pert/ppst disabled 24 pt0 ioc0 xirq v ddx pert/ppst disabled 25 pad0 kwad0 an0 v dda per1ad/pps1ad disabled 26 pad8 kwad8 an8 v dda per0ad/pps0ad disabled 27 pad1 kwad1 an1 v dda per1ad/pps1ad disabled 28 pad9 kwad9 an9 acmpo v dda per0ad/pps0ad disabled 29 pad2 kwad2 an2 v dda per1ad/pps1ad disabled 30 pad10 kwad10 an10 acmpp v dda per0ad/pps0ad disabled table 1-18. 48-pin lqfp pinout for s12ga48 and s12ga64 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 92 freescale semiconductor 31 pad3 kwad3 an3 v dda per1ad/pps1ad disabled 32 pad11 kwad11 an11 acmpm v dda per0ad/pps0ad disabled 33 pad4 kwad4 an4 v dda per1ad/pps1ad disabled 34 pad5 kwad5 an5 v dda per1ad/pps0ad disabled 35 pad6 kwad6 an6 v dda per1ad/pps1ad disabled 36 pad7 kwad7 an7 v dda per1ad/pps1ad disabled 37 vdda vrh 38 vssa 39 ps0 rxd0 v ddx pers/ppss up 40 ps1 txd0 v ddx pers/ppss up 41 ps2 rxd1 v ddx pers/ppss up 42 ps3 txd1 v ddx pers/ppss up 43 ps4 miso0 v ddx pers/ppss up 44 ps5 mosi0 v ddx pers/ppss up 45 ps6 sck0 v ddx pers/ppss up 46 ps7 api_extclk eclk ss0 v ddx pers/ppss up 47 pm0 rxcan v ddx perm/ppsm disabled 48 pm1 txcan v ddx perm/ppsm disabled 1 the regular i/o characteristics (see section a.2, ?/o characteristics ) apply if the extal/xtal function is disabled table 1-18. 48-pin lqfp pinout for s12ga48 and s12ga64 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 93 1.8.5.2 pinout 64-pin lqfp figure 1-14. 64-pin lqfp pinout for s12ga48 and s12ga64 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 s12ga48 s12ga64 64-pin lqfp pwm0/api_extclk/etrig0/kwp0/pp0 pwm1/eclkx2/etrig1/kwp1/pp1 pwm2/etrig2/kwp2/pp2 pwm3/etrig3/kwp3/pp3 pwm4/kwp4/pp4 pwm5/kwp5/pp5 kwp6/pp6 kwp7/pp7 pt7 pt6 ioc5/pt5 ioc4/pt4 ioc3/pt3 ioc2/pt2 irq/ioc1/pt1 xirq/ioc0/pt0 kwj6/pj6 kwj5/pj5 kwj4/pj4 reset vddx vddr vssx extal/pe0 vss xtal/pe1 test miso1/kwj0/pj0 mosi1/kwj1/pj1 sck1/kwj2/pj2 ss1/kwj3/pj3 bkgd pj7/kwj7 pm3 pm2 pm1/txcan pm0/rxcan ps7/api_extclk/eclk/ ss0 ps6/sck0 ps5/mosi0 ps4/miso0 ps3/txd1 ps2/rxd1 ps1/txd0 ps0/rxd0 vssa vdda vrh pad15/kwad15 pad7/kwad7/an7 pad14/kwad14 pad6/kwad6/an6 pad13/kwad13 pad5/kwad5/an5 pad12/kwad12 pad4/kwad4/an4 pad11/kwad11/an11/acmpm pad3/kwad3/an3 pad10/kwad10/an10/acmpp pad2/kwad2/an2 pad9/kwad9/an9/acmpo pad1/kwad1/an1 pad8/kwad8/an8 pad0/kwad0/an0
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 94 freescale semiconductor table 1-19. 64-pin lqfp pinout for s12ga48 and s12ga64 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state 1 pj6 kwj6 v ddx perj/ppsj up 2 pj5 kwj5 v ddx perj/ppsj up 3 pj4 kwj4 v ddx perj/ppsj up 4 reset v ddx pullup 5 vddx 6 vddr 7 vssx 8 pe0 1 extal v ddx pucr/pdpee down 9 vss 10 pe1 1 xtal v ddx pucr/pdpee down 11 test n.a. reset pin down 12 pj0 kwj0 miso1 v ddx perj/ppsj up 13 pj1 kwj1 mosi1 v ddx perj/ppsj up 14 pj2 kwj2 sck1 v ddx perj/ppsj up 15 pj3 kwj3 ss1 v ddx perj/ppsj up 16 bkgd modc v ddx pucr/bkpue up 17 pp0 kwp0 etrig0 api_extclk pwm0 v ddx perp/ppsp disabled 18 pp1 kwp1 etrig1 eclkx2 pwm1 v ddx perp/ppsp disabled 19 pp2 kwp2 etrig2 pwm2 v ddx perp/ppsp disabled 20 pp3 kwp3 etrig3 pwm3 v ddx perp/ppsp disabled 21 pp4 kwp4 pwm4 v ddx perp/ppsp disabled 22 pp5 kwp5 pwm5 v ddx perp/ppsp disabled 23 pp6 kwp6 v ddx perp/ppsp disabled 24 pp7 kwp7 v ddx perp/ppsp disabled 25 pt7 v ddx pert/ppst disabled 26 pt6 v ddx pert/ppst disabled 27 pt5 ioc5 v ddx pert/ppst disabled
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 95 28 pt4 ioc4 v ddx pert/ppst disabled 29 pt3 ioc3 v ddx pert/ppst disabled 30 pt2 ioc2 v ddx pert/ppst disabled 31 pt1 ioc1 irq v ddx pert/ppst disabled 32 pt0 ioc0 xirq v ddx pert/ppst disabled 33 pad0 kwad0 an0 v dda per1ad/pps1ad disabled 34 pad8 kwad8 an8 v dda per0ad/pps0ad disabled 35 pad1 kwad1 an1 v dda per1ad/pps1ad disabled 36 pad9 kwad9 an9 acmpo v dda per0adpps0ad disabled 37 pad2 kwad2 an2 v dda per1ad/pps1ad disabled 38 pad10 kwad10 an10 acmpp v dda per0ad/pps0ad disabled 39 pad3 kwad3 an3 v dda per1ad/pps1ad disabled 40 pad11 kwad11 an11 acmpm v dda per0ad/pps0ad disabled 41 pad4 kwad4 an4 v dda per1ad/pps1ad disabled 42 pad12 kwad12 v dda per0ad/pps0ad disabled 43 pad5 kwad5 an5 v dda per1ad/pps1ad disabled 44 pad13 kwad13 v dda per0ad/pps0ad disabled 45 pad6 kwad6 an6 v dda per1ad/pps1ad disabled 46 pad14 kwad14 v dda per0ad/pps0ad disabled 47 pad7 kwad7 an7 v dda per1ad/pps1ad disabled 48 pad15 kwad15 v dda per0ad/pps0ad disabled 49 vrh 50 vdda 51 vssa 52 ps0 rxd0 v ddx pers/ppss up 53 ps1 txd0 v ddx pers/ppss up 54 ps2 rxd1 v ddx pers/ppss up 55 ps3 txd1 v ddx pers/ppss up 56 ps4 miso0 v ddx pers/ppss up table 1-19. 64-pin lqfp pinout for s12ga48 and s12ga64 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 96 freescale semiconductor 57 ps5 mosi0 v ddx pers/ppss up 58 ps6 sck0 v ddx pers/ppss up 59 ps7 api_extclk eclk ss0 v ddx pers/ppss up 60 pm0 rxcan v ddx perm/ppsm disabled 61 pm1 txcan v ddx perm/ppsm disabled 62 pm2 v ddx perm/ppsm disabled 63 pm3 v ddx perm/ppsm disabled 64 pj7 kwj7 v ddx perj/ppsj up 1 the regular i/o characteristics (see section a.2, ?/o characteristics ) apply if the extal/xtal function is disabled table 1-19. 64-pin lqfp pinout for s12ga48 and s12ga64 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 97 1.8.6 s12g96 and s12g128 1.8.6.1 pinout 48-pin lqfp figure 1-15. 48-pin lqfp pinout for s12g96 and s12g128 table 1-20. 48-pin lqfp pinout for s12g96 and s12g128 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state 1 reset v ddx pullup 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 36 35 34 33 32 31 30 29 28 27 26 25 48 47 46 45 44 43 42 41 40 39 38 37 s12g96 s12g128 48-pin lqfp pad7/kwad7/an7 pad6/kwad6/an6 pad5/kwad5/an5 pad4/kwad4/an4 pad11/kwad11/an11 pad3/kwad3/an3 pad10/kwad10/an10 pad2/kwad2/an2 pad9/kwad9/an9 pad1/kwad1/an1 pad8/kwad8/an8 pad0/kwad0/an0 pwm0/api_extclk/etrig0/kwp0/pp0 pwm1/eclkx2/etrig1/kwp1/pp1 pwm2/etrig2/kwp2/pp2 pwm3/etrig3/kwp3/pp3 pwm4/kwp4/pp4 pwm5/kwp5/pp5 ioc5/pt5 ioc4/pt4 ioc3/pt3 ioc2/pt2 irq/ioc1/pt1 xirq/ioc0/pt0 reset vddxr vssx extal/pe0 vss xtal/pe1 test miso1/pwm6/kwj0/pj0 mosi1/ioc6/kwj1/pj1 sck1/ioc7/kwj2/pj2 ss1/pwm7/kwj3/pj3 bkgd pm1/txd2/txcan pm0/rxd2/rxcan ps7/api_extclk/eclk/ ss0 ps6/sck0 ps5/mosi0 ps4/miso0 ps3/txd1 ps2/rxd1 ps1/txd0 ps0/rxd0 vssa vdda/vrh
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 98 freescale semiconductor 2 vddxr 3 vssx 4 pe0 1 extal v ddx pucr/pdpee down 5 vss 6 pe1 1 xtal v ddx pucr/pdpee down 7 test n.a. reset pin down 8 pj0 kwj0 pwm6 miso1 v ddx perj/ppsj up 9 pj1 kwj1 ioc6 mosi1 v ddx perj/ppsj up 10 pj2 kwj2 ioc7 sck1 v ddx perj/ppsj up 11 pj3 kwj3 pwm7 ss1 v ddx perj/ppsj up 12 bkgd modc v ddx pucr/bkpue up 13 pp0 kwp0 etrig0 api_extclk pwm0 v ddx perp/ppsp disabled 14 pp1 kwp1 etrig1 eclkx2 pwm1 v ddx perp/ppsp disabled 15 pp2 kwp2 etrig2 pwm2 v ddx perp/ppsp disabled 16 pp3 kwp3 etrig3 pwm3 v ddx perp/ppsp disabled 17 pp4 kwp4 pwm4 v ddx perp/ppsp disabled 18 pp5 kwp5 pwm5 v ddx perp/ppsp disabled 19 pt5 ioc5 v ddx pert/ppst disabled 20 pt4 ioc4 v ddx pert/ppst disabled 21 pt3 ioc3 v ddx pert/ppst disabled 22 pt2 ioc2 v ddx pert/ppst disabled 23 pt1 ioc1 irq v ddx pert/ppst disabled 24 pt0 ioc0 xirq v ddx pert/ppst disabled 25 pad0 kwad0 an0 v dda per1ad/pps1ad disabled 26 pad8 kwad8 an8 v dda per0ad/pps0ad disabled 27 pad1 kwad1 an1 v dda per1ad/pps1ad disabled 28 pad9 kwad9 an9 v dda per0ad/pps0ad disabled 29 pad2 kwad2 an2 v dda per1ad/pps1ad disabled 30 pad10 kwad10 an10 v dda per0ad/pps0ad disabled table 1-20. 48-pin lqfp pinout for s12g96 and s12g128 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 99 31 pad3 kwad3 an3 v dda per1ad/pps1ad disabled 32 pad11 kwad11 an11 v dda per0ad/pps0ad disabled 33 pad4 kwad4 an4 v dda per1ad/pps1ad disabled 34 pad5 kwad5 an5 v dda per1ad/pps0ad disabled 35 pad6 kwad6 an6 v dda per1ad/pps1ad disabled 36 pad7 kwad7 an7 v dda per1ad/pps1ad disabled 37 vdda vrh 38 vssa 39 ps0 rxd0 v ddx pers/ppss up 40 ps1 txd0 v ddx pers/ppss up 41 ps2 rxd1 v ddx pers/ppss up 42 ps3 txd1 v ddx pers/ppss up 43 ps4 miso0 v ddx pers/ppss up 44 ps5 mosi0 v ddx pers/ppss up 45 ps6 sck0 v ddx pers/ppss up 46 ps7 api_extclk eclk ss0 v ddx pers/ppss up 47 pm0 rxd2 rxcan v ddx perm/ppsm disabled 48 pm1 txd2 txcan v ddx perm/ppsm disabled 1 the regular i/o characteristics (see section a.2, ?/o characteristics ) apply if the extal/xtal function is disabled table 1-20. 48-pin lqfp pinout for s12g96 and s12g128 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 100 freescale semiconductor 1.8.6.2 pinout 64-pin lqfp figure 1-16. 64-pin lqfp pinout for s12g96 and s12g128 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 s12g96 s12g128 64-pin lqfp pwm0/api_extclk/etrig0/kwp0/pp0 pwm1/eclkx2/etrig1/kwp1/pp1 pwm2/etrig2/kwp2/pp2 pwm3/etrig3/kwp3/pp3 pwm4/kwp4/pp4 pwm5/kwp5/pp5 pwm6/kwp6/pp6 pwm7/kwp7/pp7 ioc7/pt7 ioc6/pt6 ioc5/pt5 ioc4/pt4 ioc3/pt3 ioc2/pt2 irq/ioc1/pt1 xirq/ioc0/pt0 sck2/kwj6/pj6 mosi2/kwj5/pj5 miso2/kwj4/pj4 reset vddx vddr vssx extal/pe0 vss xtal/pe1 test miso1/kwj0/pj0 mosi1/kwj1/pj1 sck1/kwj2/pj2 ss1/kwj3/pj3 bkgd pj7/kwj7/ ss2 pm3/txd2 pm2/rxd2 pm1/txcan pm0/rxcan ps7/api_extclk/eclk/ ss0 ps6/sck0 ps5/mosi0 ps4/miso0 ps3/txd1 ps2/rxd1 ps1/txd0 ps0/rxd0 vssa vdda vrh pad15/kwad15 pad7/kwad7/an7 pad14/kwad14 pad6/kwad6/an6 pad13/kwad13 pad5/kwad5/an5 pad12/kwad12 pad4/kwad4/an4 pad11/kwad11/an11 pad3/kwad3/an3 pad10/kwad10/an10 pad2/kwad2/an2 pad9/kwad9/an9 pad1/kwad1/an1 pad8/kwad8/an8 pad0/kwad0/an0
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 101 table 1-21. 64-pin lqfp pinout for s12g96 and s12g128 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state 1 pj6 kwj6 sck2 v ddx perj/ppsj up 2 pj5 kwj5 mosi2 v ddx perj/ppsj up 3 pj4 kwj4 miso2 v ddx perj/ppsj up 4 reset v ddx pullup 5 vddx 6 vddr 7 vssx 8 pe0 1 extal v ddx pucr/pdpee down 9 vss 10 pe1 1 xtal v ddx pucr/pdpee down 11 test n.a. reset pin down 12 pj0 kwj0 miso1 v ddx perj/ppsj up 13 pj1 kwj1 mosi1 v ddx perj/ppsj up 14 pj2 kwj2 sck1 v ddx perj/ppsj up 15 pj3 kwj3 ss1 v ddx perj/ppsj up 16 bkgd modc v ddx pucr/bkpue up 17 pp0 kwp0 etrig0 api_extclk pwm0 v ddx perp/ppsp disabled 18 pp1 kwp1 etrig1 eclkx2 pwm1 v ddx perp/ppsp disabled 19 pp2 kwp2 etrig2 pwm2 v ddx perp/ppsp disabled 20 pp3 kwp3 etrig3 pwm3 v ddx perp/ppsp disabled 21 pp4 kwp4 pwm4 v ddx perp/ppsp disabled 22 pp5 kwp5 pwm5 v ddx perp/ppsp disabled 23 pp6 kwp6 pwm6 v ddx perp/ppsp disabled 24 pp7 kwp7 pwm7 v ddx perp/ppsp disabled 25 pt7 ioc7 v ddx pert/ppst disabled 26 pt6 ioc6 v ddx pert/ppst disabled 27 pt5 ioc5 v ddx pert/ppst disabled
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 102 freescale semiconductor 28 pt4 ioc4 v ddx pert/ppst disabled 29 pt3 ioc3 v ddx pert/ppst disabled 30 pt2 ioc2 v ddx pert/ppst disabled 31 pt1 ioc1 irq v ddx pert/ppst disabled 32 pt0 ioc0 xirq v ddx pert/ppst disabled 33 pad0 kwad0 an0 v dda per1ad/pps1ad disabled 34 pad8 kwad8 an8 v dda per0ad/pps0ad disabled 35 pad1 kwad1 an1 v dda per1ad/pps1ad disabled 36 pad9 kwad9 an9 v dda per0adpps0ad disabled 37 pad2 kwad2 an2 v dda per1ad/pps1ad disabled 38 pad10 kwad10 an10 v dda per0ad/pps0ad disabled 39 pad3 kwad3 an3 v dda per1ad/pps1ad disabled 40 pad11 kwad11 an11 v dda per0ad/pps0ad disabled 41 pad4 kwad4 an4 v dda per1ad/pps1ad disabled 42 pad12 kwad12 v dda per0ad/pps0ad disabled 43 pad5 kwad5 an5 v dda per1ad/pps1ad disabled 44 pad13 kwad13 v dda per0ad/pps0ad disabled 45 pad6 kwad6 an6 v dda per1ad/pps1ad disabled 46 pad14 kwad14 v dda per0ad/pps0ad disabled 47 pad7 kwad7 an7 v dda per1ad/pps1ad disabled 48 pad15 kwad15 v dda per0ad/pps0ad disabled 49 vrh 50 vdda 51 vssa 52 ps0 rxd0 v ddx pers/ppss up 53 ps1 txd0 v ddx pers/ppss up 54 ps2 rxd1 v ddx pers/ppss up 55 ps3 txd1 v ddx pers/ppss up 56 ps4 miso0 v ddx pers/ppss up table 1-21. 64-pin lqfp pinout for s12g96 and s12g128 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 103 57 ps5 mosi0 v ddx pers/ppss up 58 ps6 sck0 v ddx pers/ppss up 59 ps7 api_extclk eclk ss0 v ddx pers/ppss up 60 pm0 rxcan v ddx perm/ppsm disabled 61 pm1 txcan v ddx perm/ppsm disabled 62 pm2 rxd2 v ddx perm/ppsm disabled 63 pm3 txd2 v ddx perm/ppsm disabled 64 pj7 kwj7 ss2 v ddx perj/ppsj up 1 the regular i/o characteristics (see section a.2, ?/o characteristics ) apply if the extal/xtal function is disabled table 1-21. 64-pin lqfp pinout for s12g96 and s12g128 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 104 freescale semiconductor 1.8.6.3 pinout 100-pin lqfp figure 1-17. 100-pin lqfp pinout for s12g96 and s12g128 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 vrh pc7 pc6 pc5 pc4 pad15/kwad15/ pad7/kwad7/an7 pad14/kwad14 pad6/kwad6/an6 pad13/kwad13 pad5/kwad5/an5 pad12/kwad12 pad4/kwad4/an4 pad11/kwad11/an11 pad3/kwad3/an3 pad10/kwad10/an10 pad2/kwad2/an2 pad9/kwad9/an9 pad1/kwad1/an1 pad8/kwad8/an8 pad0/kwad0/an0 pc3 pc2 pc1 pc0 api_extclk/pb1 eclkx2/pb2 pb3 pwm0/etrig0/kwp0/pp0 pwm1/etrig1/kwp1/pp1 pwm2/etrig2/kwp2/pp2 pwm3/etrig3/kwp3/pp3 pwm4/kwp4/pp4 pwm5/kwp5/pp5 pwm6/kwp6/pp6 pwm7/kwp7/pp7 vddx3 vssx3 ioc7/pt7 ioc6/pt6 ioc5/pt5 ioc4/pt4 ioc3/pt3 ioc2/pt2 ioc1/pt1 ioc0/pt0 irq/pb4 xirq/pb5 pb6 pb7 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 sck2/kwj6/pj6 mosi2/kwj5/pj5 miso2/kwj4/pj4 pa 0 pa 1 pa 2 pa 3 reset vddx1 vddr vssx1 extal/pe0 vss xtal/pe1 test pa 4 pa 5 pa 6 pa 7 miso1/kwj0/pj0 mosi1/kwj1/pj1 sck1/kwj2/pj2 ss1/kwj3/pj3 bkgd eclk/pb0 pj7/kwj7/ ss2 pm3/txd2 pm2/rxd2 pd7 pd6 pd5 pd4 pm1/txcan pm0/rxcan vddx2 vssx2 ps7/api_extclk/ ss0 ps6/sck0 ps5/mosi0 ps4/miso0 ps3/txd1 ps2/rxd1 ps1/txd0 ps0/rxd0 pd3 pd2 pd1 pd0 vssa vdda s12g96 s12g128 100-pin lqfp
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 105 table 1-22. 100-pin lqfp pinout for s12g96 and s12g128 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func. ctrl reset state 1 pj6 kwj6 sck2 v ddx perj/ppsj up 2 pj5 kwj5 mosi2 v ddx perj/ppsj up 3 pj4 kwj4 miso2 v ddx perj/ppsj up 4 pa0v ddx pucr/pupae disabled 5 pa1v ddx pucr/pupae disabled 6 pa2v ddx pucr/pupae disabled 7 pa3v ddx pucr/pupae disabled 8 reset v ddx pullup 9 vddx1 10 vddr 11 vssx1 12 pe0 1 extal v ddx pucr/pdpee down 13 vss 14 pe1 1 xtal v ddx pucr/pdpee down 15 test n.a. reset pin down 16pa4v ddx pucr/pupae disabled 17pa5v ddx pucr/pupae disabled 18pa6v ddx pucr/pupae disabled 19pa7v ddx pucr/pupae disabled 20 pj0 kwj0 miso1 v ddx perj/ppsj up 21 pj1 kwj1 mosi1 v ddx perj/ppsj up 22 pj2 kwj2 sck1 v ddx perj/ppsj up 23 pj3 kwj3 ss1 v ddx perj/ppsj up 24 bkgd modc v ddx pucr/bkpue up 25 pb0 eclk v ddx pucr/pupbe disabled 26 pb1 api_extclk v ddx pucr/pupbe disabled 27 pb2 eclkx2 v ddx pucr/pupbe disabled
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 106 freescale semiconductor 28 pb3 v ddx pucr/pupbe disabled 29 pp0 kwp0 etrig0 pwm0 v ddx perp/ppsp disabled 30 pp1 kwp1 etrig1 pwm1 v ddx perp/ppsp disabled 31 pp2 kwp2 etrig2 pwm2 v ddx perp/ppsp disabled 32 pp3 kwp3 etrig3 pwm3 v ddx perp/ppsp disabled 33 pp4 kwp4 pwm4 v ddx perp/ppsp disabled 34 pp5 kwp5 pwm5 v ddx perp/ppsp disabled 35 pp6 kwp6 pwm6 v ddx perp/ppsp disabled 36 pp7 kwp7 pwm7 v ddx perp/ppsp disabled 37 vddx3 38 vssx3 39 pt7 ioc7 v ddx pert/ppst disabled 40 pt6 ioc6 v ddx pert/ppst disabled 41 pt5 ioc5 v ddx pert/ppst disabled 42 pt4 ioc4 v ddx pert/ppst disabled 43 pt3 ioc3 v ddx pert/ppst disabled 44 pt2 ioc2 v ddx pert/ppst disabled 45 pt1 ioc1 v ddx pert/ppst disabled 46 pt0 ioc0 v ddx pert/ppst disabled 47 pb4 irq v ddx pucr/pupbe disabled 48 pb5 xirq v ddx pucr/pupbe disabled 49 pb6 v ddx pucr/pupbe disabled 50 pb7 v ddx pucr/pupbe disabled 51 pc0 v dda pucr/pupce disabled 52 pc1 v dda pucr/pupce disabled 53 pc2 v dda pucr/pupce disabled 54 pc3 v dda pucr/pupce disabled 55 pad0 kwad0 an0 v dda per1ad/pps1ad disabled 56 pad8 kwad8 an8 v dda per0ad/pps0ad disabled table 1-22. 100-pin lqfp pinout for s12g96 and s12g128 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func. ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 107 57 pad1 kwad1 an1 v dda per1ad/pps1ad disabled 58 pad9 kwad9 an9 v dda per0ad/pps0ad disabled 59 pad2 kwad2 an2 v dda per1ad/pps1ad disabled 60 pad10 kwad10 an10 v dda per0ad/pps0ad disabled 61 pad3 kwad3 an3 v dda per1ad/pps1ad disabled 62 pad11 kwad11 an11 v dda per0ad/pps0ad disabled 63 pad4 kwad4 an4 v dda per1ad/pps1ad disabled 64 pad12 kwad12 v dda per0ad/pps0ad disabled 65 pad5 kwad5 an5 v dda per1ad/pps1ad disabled 66 pad13 kwad13 v dda per0ad/pps0ad disabled 67 pad6 kwad6 an6 v dda per1ad/pps1ad disabled 68 pad14 kwad14 v dda per0ad/pps0ad disabled 69 pad7 kwad7 an7 v dda per1ad/pps1ad disabled 70 pad15 kwad15 v dda per0ad/pps0ad disabled 71 pc4 v dda pucr/pupce disabled 72 pc5 v dda pucr/pupce disabled 73 pc6 v dda pucr/pupce disabled 74 pc7 v dda pucr/pupce disabled 75 vrh 76 vdda 77 vssa 78 pd0 v ddx pucr/pupde disabled 79 pd1 v ddx pucr/pupde disabled 80 pd2 v ddx pucr/pupde disabled 81 pd3 v ddx pucr/pupde disabled 82 ps0 rxd0 v ddx pers/ppss up 83 ps1 txd0 v ddx pers/ppss up 84 ps2 rxd1 v ddx pers/ppss up 85 ps3 txd1 v ddx pers/ppss up table 1-22. 100-pin lqfp pinout for s12g96 and s12g128 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func. ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 108 freescale semiconductor 86 ps4 miso0 v ddx pers/ppss up 87 ps5 mosi0 v ddx pers/ppss up 88 ps6 sck0 v ddx pers/ppss up 89 ps7 api_extclk ss0 v ddx pers/ppss up 90 vssx2 91 vddx2 92 pm0 rxcan v ddx perm/ppsm disabled 93 pm1 txcan v ddx perm/ppsm disabled 94 pd4 v ddx pucr/pupde disabled 95 pd5 v ddx pucr/pupde disabled 96 pd6 v ddx pucr/pupde disabled 97 pd7 v ddx pucr/pupde disabled 98 pm2 rxd2 v ddx perm/ppsm disabled 99 pm3 txd2 v ddx perm/ppsm disabled 100 pj7 kwj7 ss2 v ddx perj/ppsj up 1 the regular i/o characteristics (see section a.2, ?/o characteristics ) apply if the extal/xtal function is disabled table 1-22. 100-pin lqfp pinout for s12g96 and s12g128 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func. ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 109 1.8.7 s12ga96 and s12ga128 1.8.7.1 pinout 48-pin lqfp figure 1-18. 48-pin lqfp pinout for s12ga96 and s12ga128 table 1-23. 48-pin lqfp pinout for s12ga96 and s12ga128 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state 1 reset v ddx pullup 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 36 35 34 33 32 31 30 29 28 27 26 25 48 47 46 45 44 43 42 41 40 39 38 37 s12ga96 s12ga128 48-pin lqfp pad7/kwad7/an7 pad6/kwad6/an6 pad5/kwad5/an5 pad4/kwad4/an4 pad11/kwad11/an11 pad3/kwad3/an3 pad10/kwad10/an10 pad2/kwad2/an2 pad9/kwad9/an9 pad1/kwad1/an1 pad8/kwad8/an8 pad0/kwad0/an0 pwm0/api_extclk/etrig0/kwp0/pp0 pwm1/eclkx2/etrig1/kwp1/pp1 pwm2/etrig2/kwp2/pp2 pwm3/etrig3/kwp3/pp3 pwm4/kwp4/pp4 pwm5/kwp5/pp5 ioc5/pt5 ioc4/pt4 ioc3/pt3 ioc2/pt2 irq/ioc1/pt1 xirq/ioc0/pt0 reset vddxr vssx extal/pe0 vss xtal/pe1 test miso1/pwm6/kwj0/pj0 mosi1/ioc6/kwj1/pj1 sck1/ioc7/kwj2/pj2 ss1/pwm7/kwj3/pj3 bkgd pm1/txd2/txcan pm0/rxd2/rxcan ps7/api_extclk/eclk/ ss0 ps6/sck0 ps5/mosi0 ps4/miso0 ps3/txd1 ps2/rxd1 ps1/txd0 ps0/rxd0 vssa vdda/vrh
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 110 freescale semiconductor 2 vddxr 3 vssx 4 pe0 1 extal v ddx pucr/pdpee down 5 vss 6 pe1 1 xtal v ddx pucr/pdpee down 7 test n.a. reset pin down 8 pj0 kwj0 pwm6 miso1 v ddx perj/ppsj up 9 pj1 kwj1 ioc6 mosi1 v ddx perj/ppsj up 10 pj2 kwj2 ioc7 sck1 v ddx perj/ppsj up 11 pj3 kwj3 pwm7 ss1 v ddx perj/ppsj up 12 bkgd modc v ddx pucr/bkpue up 13 pp0 kwp0 etrig0 api_extclk pwm0 v ddx perp/ppsp disabled 14 pp1 kwp1 etrig1 eclkx2 pwm1 v ddx perp/ppsp disabled 15 pp2 kwp2 etrig2 pwm2 v ddx perp/ppsp disabled 16 pp3 kwp3 etrig3 pwm3 v ddx perp/ppsp disabled 17 pp4 kwp4 pwm4 v ddx perp/ppsp disabled 18 pp5 kwp5 pwm5 v ddx perp/ppsp disabled 19 pt5 ioc5 v ddx pert/ppst disabled 20 pt4 ioc4 v ddx pert/ppst disabled 21 pt3 ioc3 v ddx pert/ppst disabled 22 pt2 ioc2 v ddx pert/ppst disabled 23 pt1 ioc1 irq v ddx pert/ppst disabled 24 pt0 ioc0 xirq v ddx pert/ppst disabled 25 pad0 kwad0 an0 v dda per1ad/pps1ad disabled 26 pad8 kwad8 an8 v dda per0ad/pps0ad disabled 27 pad1 kwad1 an1 v dda per1ad/pps1ad disabled 28 pad9 kwad9 an9 v dda per0ad/pps0ad disabled 29 pad2 kwad2 an2 v dda per1ad/pps1ad disabled 30 pad10 kwad10 an10 v dda per0ad/pps0ad disabled table 1-23. 48-pin lqfp pinout for s12ga96 and s12ga128 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 111 31 pad3 kwad3 an3 v dda per1ad/pps1ad disabled 32 pad11 kwad11 an11 v dda per0ad/pps0ad disabled 33 pad4 kwad4 an4 v dda per1ad/pps1ad disabled 34 pad5 kwad5 an5 v dda per1ad/pps0ad disabled 35 pad6 kwad6 an6 v dda per1ad/pps1ad disabled 36 pad7 kwad7 an7 v dda per1ad/pps1ad disabled 37 vdda vrh 38 vssa 39 ps0 rxd0 v ddx pers/ppss up 40 ps1 txd0 v ddx pers/ppss up 41 ps2 rxd1 v ddx pers/ppss up 42 ps3 txd1 v ddx pers/ppss up 43 ps4 miso0 v ddx pers/ppss up 44 ps5 mosi0 v ddx pers/ppss up 45 ps6 sck0 v ddx pers/ppss up 46 ps7 api_extclk eclk ss0 v ddx pers/ppss up 47 pm0 rxd2 rxcan v ddx perm/ppsm disabled 48 pm1 txd2 txcan v ddx perm/ppsm disabled 1 the regular i/o characteristics (see section a.2, ?/o characteristics ) apply if the extal/xtal function is disabled table 1-23. 48-pin lqfp pinout for s12ga96 and s12ga128 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 112 freescale semiconductor 1.8.7.2 pinout 64-pin lqfp figure 1-19. 64-pin lqfp pinout for s12ga96 and s12ga128 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 s12ga96 s12ga128 64-pin lqfp pwm0/api_extclk/etrig0/kwp0/pp0 pwm1/eclkx2/etrig1/kwp1/pp1 pwm2/etrig2/kwp2/pp2 pwm3/etrig3/kwp3/pp3 pwm4/kwp4/pp4 pwm5/kwp5/pp5 pwm6/kwp6/pp6 pwm7/kwp7/pp7 ioc7/pt7 ioc6/pt6 ioc5/pt5 ioc4/pt4 ioc3/pt3 ioc2/pt2 irq/ioc1/pt1 xirq/ioc0/pt0 sck2/kwj6/pj6 mosi2/kwj5/pj5 miso2/kwj4/pj4 reset vddx vddr vssx extal/pe0 vss xtal/pe1 test miso1/kwj0/pj0 mosi1/kwj1/pj1 sck1/kwj2/pj2 ss1/kwj3/pj3 bkgd pj7/kwj7/ ss2 pm3/txd2 pm2/rxd2 pm1/txcan pm0/rxcan ps7/api_extclk/eclk/ ss0 ps6/sck0 ps5/mosi0 ps4/miso0 ps3/txd1 ps2/rxd1 ps1/txd0 ps0/rxd0 vssa vdda vrh pad15/kwad15 pad7/kwad7/an7 pad14/kwad14 pad6/kwad6/an6 pad13/kwad13 pad5/kwad5/an5 pad12/kwad12 pad4/kwad4/an4 pad11/kwad11/an11 pad3/kwad3/an3 pad10/kwad10/an10 pad2/kwad2/an2 pad9/kwad9/an9 pad1/kwad1/an1 pad8/kwad8/an8 pad0/kwad0/an0
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 113 table 1-24. 64-pin lqfp pinout for s12ga96 and s12ga128 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state 1 pj6 kwj6 sck2 v ddx perj/ppsj up 2 pj5 kwj5 mosi2 v ddx perj/ppsj up 3 pj4 kwj4 miso2 v ddx perj/ppsj up 4 reset v ddx pullup 5 vddx 6 vddr 7 vssx 8 pe0 1 extal v ddx pucr/pdpee down 9 vss 10 pe1 1 xtal v ddx pucr/pdpee down 11 test n.a. reset pin down 12 pj0 kwj0 miso1 v ddx perj/ppsj up 13 pj1 kwj1 mosi1 v ddx perj/ppsj up 14 pj2 kwj2 sck1 v ddx perj/ppsj up 15 pj3 kwj3 ss1 v ddx perj/ppsj up 16 bkgd modc v ddx pucr/bkpue up 17 pp0 kwp0 etrig0 api_extclk pwm0 v ddx perp/ppsp disabled 18 pp1 kwp1 etrig1 eclkx2 pwm1 v ddx perp/ppsp disabled 19 pp2 kwp2 etrig2 pwm2 v ddx perp/ppsp disabled 20 pp3 kwp3 etrig3 pwm3 v ddx perp/ppsp disabled 21 pp4 kwp4 pwm4 v ddx perp/ppsp disabled 22 pp5 kwp5 pwm5 v ddx perp/ppsp disabled 23 pp6 kwp6 pwm6 v ddx perp/ppsp disabled 24 pp7 kwp7 pwm7 v ddx perp/ppsp disabled 25 pt7 ioc7 v ddx pert/ppst disabled 26 pt6 ioc6 v ddx pert/ppst disabled 27 pt5 ioc5 v ddx pert/ppst disabled
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 114 freescale semiconductor 28 pt4 ioc4 v ddx pert/ppst disabled 29 pt3 ioc3 v ddx pert/ppst disabled 30 pt2 ioc2 v ddx pert/ppst disabled 31 pt1 ioc1 irq v ddx pert/ppst disabled 32 pt0 ioc0 xirq v ddx pert/ppst disabled 33 pad0 kwad0 an0 v dda per1ad/pps1ad disabled 34 pad8 kwad8 an8 v dda per0ad/pps0ad disabled 35 pad1 kwad1 an1 v dda per1ad/pps1ad disabled 36 pad9 kwad9 an9 v dda per0adpps0ad disabled 37 pad2 kwad2 an2 v dda per1ad/pps1ad disabled 38 pad10 kwad10 an10 v dda per0ad/pps0ad disabled 39 pad3 kwad3 an3 v dda per1ad/pps1ad disabled 40 pad11 kwad11 an11 v dda per0ad/pps0ad disabled 41 pad4 kwad4 an4 v dda per1ad/pps1ad disabled 42 pad12 kwad12 v dda per0ad/pps0ad disabled 43 pad5 kwad5 an5 v dda per1ad/pps1ad disabled 44 pad13 kwad13 v dda per0ad/pps0ad disabled 45 pad6 kwad6 an6 v dda per1ad/pps1ad disabled 46 pad14 kwad14 v dda per0ad/pps0ad disabled 47 pad7 kwad7 an7 v dda per1ad/pps1ad disabled 48 pad15 kwad15 v dda per0ad/pps0ad disabled 49 vrh 50 vdda 51 vssa 52 ps0 rxd0 v ddx pers/ppss up 53 ps1 txd0 v ddx pers/ppss up 54 ps2 rxd1 v ddx pers/ppss up 55 ps3 txd1 v ddx pers/ppss up 56 ps4 miso0 v ddx pers/ppss up table 1-24. 64-pin lqfp pinout for s12ga96 and s12ga128 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 115 57 ps5 mosi0 v ddx pers/ppss up 58 ps6 sck0 v ddx pers/ppss up 59 ps7 api_extclk eclk ss0 v ddx pers/ppss up 60 pm0 rxcan v ddx perm/ppsm disabled 61 pm1 txcan v ddx perm/ppsm disabled 62 pm2 rxd2 v ddx perm/ppsm disabled 63 pm3 txd2 v ddx perm/ppsm disabled 64 pj7 kwj7 ss2 v ddx perj/ppsj up 1 the regular i/o characteristics (see section a.2, ?/o characteristics ) apply if the extal/xtal function is disabled table 1-24. 64-pin lqfp pinout for s12ga96 and s12ga128 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 116 freescale semiconductor 1.8.7.3 pinout 100-pin lqfp figure 1-20. 100-pin lqfp pinout for s12ga96 and s12ga128 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 vrh pc7 pc6 pc5 pc4 pad15/kwad15/ pad7/kwad7/an7 pad14/kwad14 pad6/kwad6/an6 pad13/kwad13 pad5/kwad5/an5 pad12/kwad12 pad4/kwad4/an4 pad11/kwad11/an11 pad3/kwad3/an3 pad10/kwad10/an10 pad2/kwad2/an2 pad9/kwad9/an9 pad1/kwad1/an1 pad8/kwad8/an8 pad0/kwad0/an0 pc3 pc2 pc1 pc0 api_extclk/pb1 eclkx2/pb2 pb3 pwm0/etrig0/kwp0/pp0 pwm1/etrig1/kwp1/pp1 pwm2/etrig2/kwp2/pp2 pwm3/etrig3/kwp3/pp3 pwm4/kwp4/pp4 pwm5/kwp5/pp5 pwm6/kwp6/pp6 pwm7/kwp7/pp7 vddx3 vssx3 ioc7/pt7 ioc6/pt6 ioc5/pt5 ioc4/pt4 ioc3/pt3 ioc2/pt2 ioc1/pt1 ioc0/pt0 irq/pb4 xirq/pb5 pb6 pb7 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 sck2/kwj6/pj6 mosi2/kwj5/pj5 miso2/kwj4/pj4 pa 0 pa 1 pa 2 pa 3 reset vddx1 vddr vssx1 extal/pe0 vss xtal/pe1 test pa 4 pa 5 pa 6 pa 7 miso1/kwj0/pj0 mosi1/kwj1/pj1 sck1/kwj2/pj2 ss1/kwj3/pj3 bkgd eclk/pb0 pj7/kwj7/ ss2 pm3/txd2 pm2/rxd2 pd7 pd6 pd5 pd4 pm1/txcan pm0/rxcan vddx2 vssx2 ps7/api_extclk/ ss0 ps6/sck0 ps5/mosi0 ps4/miso0 ps3/txd1 ps2/rxd1 ps1/txd0 ps0/rxd0 pd3 pd2 pd1 pd0 vssa vdda s12ga96 s12ga128 100-pin lqfp
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 117 table 1-25. 100-pin lqfp pinout for s12ga96 and s12ga128 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func. ctrl reset state 1 pj6 kwj6 sck2 v ddx perj/ppsj up 2 pj5 kwj5 mosi2 v ddx perj/ppsj up 3 pj4 kwj4 miso2 v ddx perj/ppsj up 4 pa0v ddx pucr/pupae disabled 5 pa1v ddx pucr/pupae disabled 6 pa2v ddx pucr/pupae disabled 7 pa3v ddx pucr/pupae disabled 8 reset v ddx pullup 9 vddx1 10 vddr 11 vssx1 12 pe0 1 extal v ddx pucr/pdpee down 13 vss 14 pe1 1 xtal v ddx pucr/pdpee down 15 test n.a. reset pin down 16pa4v ddx pucr/pupae disabled 17pa5v ddx pucr/pupae disabled 18pa6v ddx pucr/pupae disabled 19pa7v ddx pucr/pupae disabled 20 pj0 kwj0 miso1 v ddx perj/ppsj up 21 pj1 kwj1 mosi1 v ddx perj/ppsj up 22 pj2 kwj2 sck1 v ddx perj/ppsj up 23 pj3 kwj3 ss1 v ddx perj/ppsj up 24 bkgd modc v ddx pucr/bkpue up 25 pb0 eclk v ddx pucr/pupbe disabled 26 pb1 api_extclk v ddx pucr/pupbe disabled 27 pb2 eclkx2 v ddx pucr/pupbe disabled
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 118 freescale semiconductor 28 pb3 v ddx pucr/pupbe disabled 29 pp0 kwp0 etrig0 pwm0 v ddx perp/ppsp disabled 30 pp1 kwp1 etrig1 pwm1 v ddx perp/ppsp disabled 31 pp2 kwp2 etrig2 pwm2 v ddx perp/ppsp disabled 32 pp3 kwp3 etrig3 pwm3 v ddx perp/ppsp disabled 33 pp4 kwp4 pwm4 v ddx perp/ppsp disabled 34 pp5 kwp5 pwm5 v ddx perp/ppsp disabled 35 pp6 kwp6 pwm6 v ddx perp/ppsp disabled 36 pp7 kwp7 pwm7 v ddx perp/ppsp disabled 37 vddx3 38 vssx3 39 pt7 ioc7 v ddx pert/ppst disabled 40 pt6 ioc6 v ddx pert/ppst disabled 41 pt5 ioc5 v ddx pert/ppst disabled 42 pt4 ioc4 v ddx pert/ppst disabled 43 pt3 ioc3 v ddx pert/ppst disabled 44 pt2 ioc2 v ddx pert/ppst disabled 45 pt1 ioc1 v ddx pert/ppst disabled 46 pt0 ioc0 v ddx pert/ppst disabled 47 pb4 irq v ddx pucr/pupbe disabled 48 pb5 xirq v ddx pucr/pupbe disabled 49 pb6 v ddx pucr/pupbe disabled 50 pb7 v ddx pucr/pupbe disabled 51 pc0 v dda pucr/pupce disabled 52 pc1 v dda pucr/pupce disabled 53 pc2 v dda pucr/pupce disabled 54 pc3 v dda pucr/pupce disabled 55 pad0 kwad0 an0 v dda per1ad/pps1ad disabled 56 pad8 kwad8 an8 v dda per0ad/pps0ad disabled table 1-25. 100-pin lqfp pinout for s12ga96 and s12ga128 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func. ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 119 57 pad1 kwad1 an1 v dda per1ad/pps1ad disabled 58 pad9 kwad9 an9 v dda per0ad/pps0ad disabled 59 pad2 kwad2 an2 v dda per1ad/pps1ad disabled 60 pad10 kwad10 an10 v dda per0ad/pps0ad disabled 61 pad3 kwad3 an3 v dda per1ad/pps1ad disabled 62 pad11 kwad11 an11 v dda per0ad/pps0ad disabled 63 pad4 kwad4 an4 v dda per1ad/pps1ad disabled 64 pad12 kwad12 v dda per0ad/pps0ad disabled 65 pad5 kwad5 an5 v dda per1ad/pps1ad disabled 66 pad13 kwad13 v dda per0ad/pps0ad disabled 67 pad6 kwad6 an6 v dda per1ad/pps1ad disabled 68 pad14 kwad14 v dda per0ad/pps0ad disabled 69 pad7 kwad7 an7 v dda per1ad/pps1ad disabled 70 pad15 kwad15 v dda per0ad/pps0ad disabled 71 pc4 v dda pucr/pupce disabled 72 pc5 v dda pucr/pupce disabled 73 pc6 v dda pucr/pupce disabled 74 pc7 v dda pucr/pupce disabled 75 vrh 76 vdda 77 vssa 78 pd0 v ddx pucr/pupde disabled 79 pd1 v ddx pucr/pupde disabled 80 pd2 v ddx pucr/pupde disabled 81 pd3 v ddx pucr/pupde disabled 82 ps0 rxd0 v ddx pers/ppss up 83 ps1 txd0 v ddx pers/ppss up 84 ps2 rxd1 v ddx pers/ppss up 85 ps3 txd1 v ddx pers/ppss up table 1-25. 100-pin lqfp pinout for s12ga96 and s12ga128 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func. ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 120 freescale semiconductor 86 ps4 miso0 v ddx pers/ppss up 87 ps5 mosi0 v ddx pers/ppss up 88 ps6 sck0 v ddx pers/ppss up 89 ps7 api_extclk ss0 v ddx pers/ppss up 90 vssx2 91 vddx2 92 pm0 rxcan v ddx perm/ppsm disabled 93 pm1 txcan v ddx perm/ppsm disabled 94 pd4 v ddx pucr/pupde disabled 95 pd5 v ddx pucr/pupde disabled 96 pd6 v ddx pucr/pupde disabled 97 pd7 v ddx pucr/pupde disabled 98 pm2 rxd2 v ddx perm/ppsm disabled 99 pm3 txd2 v ddx perm/ppsm disabled 100 pj7 kwj7 ss2 v ddx perj/ppsj up 1 the regular i/o characteristics (see section a.2, ?/o characteristics ) apply if the extal/xtal function is disabled table 1-25. 100-pin lqfp pinout for s12ga96 and s12ga128 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func. ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 121 1.8.8 s12g192 and s12g240 1.8.8.1 pinout 48-pin lqfp figure 1-21. 48-pin lqfp pinout for s12g192 and s12g240 table 1-26. 48-pin lqfp pinout for s12g192 and s12g240 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state 1 reset v ddx pullup 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 36 35 34 33 32 31 30 29 28 27 26 25 48 47 46 45 44 43 42 41 40 39 38 37 s12g192 s12g240 48-pin lqfp pad7/kwad7/an7 pad6/kwad6/an6 pad5/kwad5/an5 pad4/kwad4/an4 pad11/kwad11/an11 pad3/kwad3/an3 pad10/kwad10/an10 pad2/kwad2/an2 pad9/kwad9/an9 pad1/kwad1/an1 pad8/kwad8/an8 pad0/kwad0/an0 pwm0/api_extclk/etrig0/kwp0/pp0 pwm1/eclkx2/etrig1/kwp1/pp1 pwm2/etrig2/kwp2/pp2 pwm3/etrig3/kwp3/pp3 pwm4/kwp4/pp4 pwm5/kwp5/pp5 ioc5/pt5 ioc4/pt4 ioc3/pt3 ioc2/pt2 irq/ioc1/pt1 xirq/ioc0/pt0 reset vddxr vssx extal/pe0 vss xtal/pe1 test miso1/pwm6/kwj0/pj0 mosi1/ioc6/kwj1/pj1 sck1/ioc7/kwj2/pj2 ss1/pwm7/kwj3/pj3 bkgd pm1/txd2/txcan pm0/rxd2/rxcan ps7/api_extclk/eclk/ ss0 ps6/sck0 ps5/mosi0 ps4/miso0 ps3/txd1 ps2/rxd1 ps1/txd0 ps0/rxd0 vssa vdda/vrh
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 122 freescale semiconductor 2 vddxr 3 vssx 4 pe0 1 extal v ddx pucr/pdpee down 5 vss 6 pe1 1 xtal v ddx pucr/pdpee down 7 test n.a. reset pin down 8 pj0 kwj0 pwm6 miso1 v ddx perj/ppsj up 9 pj1 kwj1 ioc6 mosi1 v ddx perj/ppsj up 10 pj2 kwj2 ioc7 sck1 v ddx perj/ppsj up 11 pj3 kwj3 pwm7 ss1 v ddx perj/ppsj up 12 bkgd modc v ddx pucr/bkpue up 13 pp0 kwp0 etrig0 api_extclk pwm0 v ddx perp/ppsp disabled 14 pp1 kwp1 etrig1 eclkx2 pwm1 v ddx perp/ppsp disabled 15 pp2 kwp2 etrig2 pwm2 v ddx perp/ppsp disabled 16 pp3 kwp3 etrig3 pwm3 v ddx perp/ppsp disabled 17 pp4 kwp4 pwm4 v ddx perp/ppsp disabled 18 pp5 kwp5 pwm5 v ddx perp/ppsp disabled 19 pt5 ioc5 v ddx pert/ppst disabled 20 pt4 ioc4 v ddx pert/ppst disabled 21 pt3 ioc3 v ddx pert/ppst disabled 22 pt2 ioc2 v ddx pert/ppst disabled 23 pt1 ioc1 irq v ddx pert/ppst disabled 24 pt0 ioc0 xirq v ddx pert/ppst disabled 25 pad0 kwad0 an0 v dda per1ad/pps1ad disabled 26 pad8 kwad8 an8 v dda per0ad/pps0ad disabled 27 pad1 kwad1 an1 v dda per1ad/pps1ad disabled 28 pad9 kwad9 an9 v dda per0ad/pps0ad disabled 29 pad2 kwad2 an2 v dda per1ad/pps1ad disabled 30 pad10 kwad10 an10 v dda per0ad/pps0ad disabled table 1-26. 48-pin lqfp pinout for s12g192 and s12g240 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 123 31 pad3 kwad3 an3 v dda per1ad/pps1ad disabled 32 pad11 kwad11 an11 v dda per0ad/pps0ad disabled 33 pad4 kwad4 an4 v dda per1ad/pps1ad disabled 34 pad5 kwad5 an5 v dda per1ad/pps0ad disabled 35 pad6 kwad6 an6 v dda per1ad/pps1ad disabled 36 pad7 kwad7 an7 v dda per1ad/pps1ad disabled 37 vdda vrh 38 vssa 39 ps0 rxd0 v ddx pers/ppss up 40 ps1 txd0 v ddx pers/ppss up 41 ps2 rxd1 v ddx pers/ppss up 42 ps3 txd1 v ddx pers/ppss up 43 ps4 miso0 v ddx pers/ppss up 44 ps5 mosi0 v ddx pers/ppss up 45 ps6 sck0 v ddx pers/ppss up 46 ps7 api_extclk eclk ss0 v ddx pers/ppss up 47 pm0 rxd2 rxcan v ddx perm/ppsm disabled 48 pm1 txd2 txcan v ddx perm/ppsm disabled 1 the regular i/o characteristics (see section a.2, ?/o characteristics ) apply if the extal/xtal function is disabled table 1-26. 48-pin lqfp pinout for s12g192 and s12g240 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 124 freescale semiconductor 1.8.8.2 pinout 64-pin lqfp figure 1-22. 64-pin lqfp pinout for s12g192 and s12g240 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 s12g192 s12g240 64-pin lqfp pwm0/api_extclk/etrig0/kwp0/pp0 pwm1/eclkx2/etrig1/kwp1/pp1 pwm2/etrig2/kwp2/pp2 pwm3/etrig3/kwp3/pp3 pwm4/kwp4/pp4 pwm5/kwp5/pp5 pwm6/kwp6/pp6 pwm7/kwp7/pp7 ioc7/pt7 ioc6/pt6 ioc5/pt5 ioc4/pt4 ioc3/pt3 ioc2/pt2 irq/ioc1/pt1 xirq/ioc0/pt0 sck2/kwj6/pj6 mosi2/kwj5/pj5 miso2/kwj4/pj4 reset vddx vddr vssx extal/pe0 vss xtal/pe1 test miso1/kwj0/pj0 mosi1/kwj1/pj1 sck1/kwj2/pj2 ss1/kwj3/pj3 bkgd pj7/kwj7/ ss2 pm3/txd2 pm2/rxd2 pm1/txcan pm0/rxcan ps7/api_extclk/eclk/ ss0 ps6/sck0 ps5/mosi0 ps4/miso0 ps3/txd1 ps2/rxd1 ps1/txd0 ps0/rxd0 vssa vdda vrh pad15/kwad15/an15 pad7/kwad7/an7 pad14/kwad14/an14 pad6/kwad6/an6 pad13/kwad13/an13 pad5/kwad5/an5 pad12/kwad12/an12 pad4/kwad4/an4 pad11/kwad11/an11 pad3/kwad3/an3 pad10/kwad10/an10 pad2/kwad2/an2 pad9/kwad9/an9 pad1/kwad1/an1 pad8/kwad8/an8 pad0/kwad0/an0
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 125 table 1-27. 64-pin lqfp pinout for s12g192 and s12g240 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state 1 pj6 kwj6 sck2 v ddx perj/ppsj up 2 pj5 kwj5 mosi2 v ddx perj/ppsj up 3 pj4 kwj4 miso2 v ddx perj/ppsj up 4 reset v ddx pullup 5 vddx 6 vddr 7 vssx 8 pe0 1 extal v ddx pucr/pdpee down 9 vss 10 pe1 1 xtal v ddx pucr/pdpee down 11 test n.a. reset pin down 12 pj0 kwj0 miso1 v ddx perj/ppsj up 13 pj1 kwj1 mosi1 v ddx perj/ppsj up 14 pj2 kwj2 sck1 v ddx perj/ppsj up 15 pj3 kwj3 ss1 v ddx perj/ppsj up 16 bkgd modc v ddx pucr/bkpue up 17 pp0 kwp0 etrig0 api_extclk pwm0 v ddx perp/ppsp disabled 18 pp1 kwp1 etrig1 eclkx2 pwm1 v ddx perp/ppsp disabled 19 pp2 kwp2 etrig2 pwm2 v ddx perp/ppsp disabled 20 pp3 kwp3 etrig3 pwm3 v ddx perp/ppsp disabled 21 pp4 kwp4 pwm4 v ddx perp/ppsp disabled 22 pp5 kwp5 pwm5 v ddx perp/ppsp disabled 23 pp6 kwp6 pwm6 v ddx perp/ppsp disabled 24 pp7 kwp7 pwm7 v ddx perp/ppsp disabled 25 pt7 ioc7 v ddx pert/ppst disabled 26 pt6 ioc6 v ddx pert/ppst disabled 27 pt5 ioc5 v ddx pert/ppst disabled
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 126 freescale semiconductor 28 pt4 ioc4 v ddx pert/ppst disabled 29 pt3 ioc3 v ddx pert/ppst disabled 30 pt2 ioc2 v ddx pert/ppst disabled 31 pt1 ioc1 irq v ddx pert/ppst disabled 32 pt0 ioc0 xirq v ddx pert/ppst disabled 33 pad0 kwad0 an0 v dda per1ad/pps1ad disabled 34 pad8 kwad8 an8 v dda per0ad/pps0ad disabled 35 pad1 kwad1 an1 v dda per1ad/pps1ad disabled 36 pad9 kwad9 an9 v dda per0adpps0ad disabled 37 pad2 kwad2 an2 v dda per1ad/pps1ad disabled 38 pad10 kwad10 an10 v dda per0ad/pps0ad disabled 39 pad3 kwad3 an3 v dda per1ad/pps1ad disabled 40 pad11 kwad11 an11 v dda per0ad/pps0ad disabled 41 pad4 kwad4 an4 v dda per1ad/pps1ad disabled 42 pad12 kwad12 an12 v dda per0ad/pps0ad disabled 43 pad5 kwad5 an5 v dda per1ad/pps1ad disabled 44 pad13 kwad13 an13 v dda per0ad/pps0ad disabled 45 pad6 kwad6 an6 v dda per1ad/pps1ad disabled 46 pad14 kwad14 an14 v dda per0ad/pps0ad disabled 47 pad7 kwad7 an7 v dda per1ad/pps1ad disabled 48 pad15 kwad15 an15 v dda per0ad/pps0ad disabled 49 vrh 50 vdda 51 vssa 52 ps0 rxd0 v ddx pers/ppss up 53 ps1 txd0 v ddx pers/ppss up 54 ps2 rxd1 v ddx pers/ppss up 55 ps3 txd1 v ddx pers/ppss up 56 ps4 miso0 v ddx pers/ppss up table 1-27. 64-pin lqfp pinout for s12g192 and s12g240 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 127 57 ps5 mosi0 v ddx pers/ppss up 58 ps6 sck0 v ddx pers/ppss up 59 ps7 api_extclk eclk ss0 v ddx pers/ppss up 60 pm0 rxcan v ddx perm/ppsm disabled 61 pm1 txcan v ddx perm/ppsm disabled 62 pm2 rxd2 v ddx perm/ppsm disabled 63 pm3 txd2 v ddx perm/ppsm disabled 64 pj7 kwj7 ss2 v ddx perj/ppsj up 1 the regular i/o characteristics (see section a.2, ?/o characteristics ) apply if the extal/xtal function is disabled table 1-27. 64-pin lqfp pinout for s12g192 and s12g240 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 128 freescale semiconductor 1.8.8.3 pinout 100-pin lqfp figure 1-23. 100-pin lqfp pinout for s12g192 and s12g240 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 vrh pc7 pc6 pc5 pc4 pad15/kwad15/an15 pad7/kwad7/an7 pad14/kwad14/an14 pad6/kwad6/an6 pad13/kwad13/an13 pad5/kwad5/an5 pad12/kwad12/an12 pad4/kwad4/an4 pad11/kwad11/an11 pad3/kwad3/an3 pad10/kwad10/an10 pad2/kwad2/an2 pad9/kwad9/an9 pad1/kwad1/an1 pad8/kwad8/an8 pad0/kwad0/an0 pc3 pc2 pc1 pc0 api_extclk/pb1 eclkx2/pb2 pb3 pwm0/etrig0/kwp0/pp0 pwm1/etrig1/kwp1/pp1 pwm2/etrig2/kwp2/pp2 pwm3/etrig3/kwp3/pp3 pwm4/kwp4/pp4 pwm5/kwp5/pp5 pwm6/kwp6/pp6 pwm7/kwp7/pp7 vddx3 vssx3 ioc7/pt7 ioc6/pt6 ioc5/pt5 ioc4/pt4 ioc3/pt3 ioc2/pt2 ioc1/pt1 ioc0/pt0 irq/pb4 xirq/pb5 pb6 pb7 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 sck2/kwj6/pj6 mosi2/kwj5/pj5 miso2/kwj4/pj4 pa 0 pa 1 pa 2 pa 3 reset vddx1 vddr vssx1 extal/pe0 vss xtal/pe1 test pa 4 pa 5 pa 6 pa 7 miso1/kwj0/pj0 mosi1/kwj1/pj1 sck1/kwj2/pj2 ss1/kwj3/pj3 bkgd eclk/pb0 pj7/kwj7/ ss2 pm3/txd2 pm2/rxd2 pd7 pd6 pd5 pd4 pm1/txcan pm0/rxcan vddx2 vssx2 ps7/api_extclk/ ss0 ps6/sck0 ps5/mosi0 ps4/miso0 ps3/txd1 ps2/rxd1 ps1/txd0 ps0/rxd0 pd3 pd2 pd1 pd0 vssa vdda s12g192 s12g240 100-pin lqfp
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 129 table 1-28. 100-pin lqfp pinout for s12g192 and s12g240 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func. ctrl reset state 1 pj6 kwj6 sck2 v ddx perj/ppsj up 2 pj5 kwj5 mosi2 v ddx perj/ppsj up 3 pj4 kwj4 miso2 v ddx perj/ppsj up 4 pa0v ddx pucr/pupae disabled 5 pa1v ddx pucr/pupae disabled 6 pa2v ddx pucr/pupae disabled 7 pa3v ddx pucr/pupae disabled 8 reset v ddx pullup 9 vddx1 10 vddr 11 vssx1 12 pe0 1 extal v ddx pucr/pdpee down 13 vss 14 pe1 1 xtal v ddx pucr/pdpee down 15 test n.a. reset pin down 16pa4v ddx pucr/pupae disabled 17pa5v ddx pucr/pupae disabled 18pa6v ddx pucr/pupae disabled 19pa7v ddx pucr/pupae disabled 20 pj0 kwj0 miso1 v ddx perj/ppsj up 21 pj1 kwj1 mosi1 v ddx perj/ppsj up 22 pj2 kwj2 sck1 v ddx perj/ppsj up 23 pj3 kwj3 ss1 v ddx perj/ppsj up 24 bkgd modc v ddx pucr/bkpue up 25 pb0 eclk v ddx pucr/pupbe disabled 26 pb1 api_extclk v ddx pucr/pupbe disabled 27 pb2 eclkx2 v ddx pucr/pupbe disabled
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 130 freescale semiconductor 28 pb3 v ddx pucr/pupbe disabled 29 pp0 kwp0 etrig0 pwm0 v ddx perp/ppsp disabled 30 pp1 kwp1 etrig1 pwm1 v ddx perp/ppsp disabled 31 pp2 kwp2 etrig2 pwm2 v ddx perp/ppsp disabled 32 pp3 kwp3 etrig3 pwm3 v ddx perp/ppsp disabled 33 pp4 kwp4 pwm4 v ddx perp/ppsp disabled 34 pp5 kwp5 pwm5 v ddx perp/ppsp disabled 35 pp6 kwp6 pwm6 v ddx perp/ppsp disabled 36 pp7 kwp7 pwm7 v ddx perp/ppsp disabled 37 vddx3 38 vssx3 39 pt7 ioc7 v ddx pert/ppst disabled 40 pt6 ioc6 v ddx pert/ppst disabled 41 pt5 ioc5 v ddx pert/ppst disabled 42 pt4 ioc4 v ddx pert/ppst disabled 43 pt3 ioc3 v ddx pert/ppst disabled 44 pt2 ioc2 v ddx pert/ppst disabled 45 pt1 ioc1 v ddx pert/ppst disabled 46 pt0 ioc0 v ddx pert/ppst disabled 47 pb4 irq v ddx pucr/pupbe disabled 48 pb5 xirq v ddx pucr/pupbe disabled 49 pb6 v ddx pucr/pupbe disabled 50 pb7 v ddx pucr/pupbe disabled 51 pc0 v dda pucr/pupce disabled 52 pc1 v dda pucr/pupce disabled 53 pc2 v dda pucr/pupce disabled 54 pc3 v dda pucr/pupce disabled 55 pad0 kwad0 an0 v dda per1ad/pps1ad disabled 56 pad8 kwad8 an8 v dda per0ad/pps0ad disabled table 1-28. 100-pin lqfp pinout for s12g192 and s12g240 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func. ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 131 57 pad1 kwad1 an1 v dda per1ad/pps1ad disabled 58 pad9 kwad9 an9 v dda per0ad/pps0ad disabled 59 pad2 kwad2 an2 v dda per1ad/pps1ad disabled 60 pad10 kwad10 an10 v dda per0ad/pps0ad disabled 61 pad3 kwad3 an3 v dda per1ad/pps1ad disabled 62 pad11 kwad11 an11 v dda per0ad/pps0ad disabled 63 pad4 kwad4 an4 v dda per1ad/pps1ad disabled 64 pad12 kwad12 an12 v dda per0ad/pps0ad disabled 65 pad5 kwad5 an5 v dda per1ad/pps1ad disabled 66 pad13 kwad13 an13 v dda per0ad/pps0ad disabled 67 pad6 kwad6 an6 v dda per1ad/pps1ad disabled 68 pad14 kwad14 an14 v dda per0ad/pps0ad disabled 69 pad7 kwad7 an7 v dda per1ad/pps1ad disabled 70 pad15 kwad15 an15 v dda per0ad/pps0ad disabled 71 pc4 v dda pucr/pupce disabled 72 pc5 v dda pucr/pupce disabled 73 pc6 v dda pucr/pupce disabled 74 pc7 v dda pucr/pupce disabled 75 vrh 76 vdda 77 vssa 78 pd0 v ddx pucr/pupde disabled 79 pd1 v ddx pucr/pupde disabled 80 pd2 v ddx pucr/pupde disabled 81 pd3 v ddx pucr/pupde disabled 82 ps0 rxd0 v ddx pers/ppss up 83 ps1 txd0 v ddx pers/ppss up 84 ps2 rxd1 v ddx pers/ppss up 85 ps3 txd1 v ddx pers/ppss up table 1-28. 100-pin lqfp pinout for s12g192 and s12g240 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func. ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 132 freescale semiconductor 86 ps4 miso0 v ddx pers/ppss up 87 ps5 mosi0 v ddx pers/ppss up 88 ps6 sck0 v ddx pers/ppss up 89 ps7 api_extclk ss0 v ddx pers/ppss up 90 vssx2 91 vddx2 92 pm0 rxcan v ddx perm/ppsm disabled 93 pm1 txcan v ddx perm/ppsm disabled 94 pd4 v ddx pucr/pupde disabled 95 pd5 v ddx pucr/pupde disabled 96 pd6 v ddx pucr/pupde disabled 97 pd7 v ddx pucr/pupde disabled 98 pm2 rxd2 v ddx perm/ppsm disabled 99 pm3 txd2 v ddx perm/ppsm disabled 100 pj7 kwj7 ss2 v ddx perj/ppsj up 1 the regular i/o characteristics (see section a.2, ?/o characteristics ) apply if the extal/xtal function is disabled table 1-28. 100-pin lqfp pinout for s12g192 and s12g240 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func. ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 133 1.8.9 s12ga192 and s12ga240 1.8.9.1 pinout 48-pin lqfp figure 1-24. 48-pin lqfp pinout for s12ga192 and s12ga240 table 1-29. 48-pin lqfp pinout for s12ga192 and s12ga240 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state 1 reset v ddx pullup 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 36 35 34 33 32 31 30 29 28 27 26 25 48 47 46 45 44 43 42 41 40 39 38 37 s12ga192 s12ga240 48-pin lqfp pad7/kwad7/an7 pad6/kwad6/an6 pad5/kwad5/an5 pad4/kwad4/an4 pad11/kwad11/an11/dacu0/amp0 pad3/kwad3/an3 pad10/kwad10/an10/dacu1/amp1 pad2/kwad2/an2 pad9/kwad9/an9 pad1/kwad1/an1 pad8/kwad8/an8 pad0/kwad0/an0 pwm0/api_extclk/etrig0/kwp0/pp0 pwm1/eclkx2/etrig1/kwp1/pp1 pwm2/etrig2/kwp2/pp2 pwm3/etrig3/kwp3/pp3 pwm4/kwp4/pp4 pwm5/kwp5/pp5 ioc5/pt5 ioc4/pt4 ioc3/pt3 ioc2/pt2 irq/ioc1/pt1 xirq/ioc0/pt0 reset vddxr vssx extal/pe0 vss xtal/pe1 test miso1/pwm6/kwj0/pj0 mosi1/ioc6/kwj1/pj1 sck1/ioc7/kwj2/pj2 ss1/pwm7/kwj3/pj3 bkgd pm1/txd2/txcan pm0/rxd2/rxcan ps7/api_extclk/eclk/ ss0 ps6/sck0 ps5/mosi0 ps4/miso0 ps3/txd1 ps2/rxd1 ps1/txd0 ps0/rxd0 vssa vdda/vrh
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 134 freescale semiconductor 2 vddxr 3 vssx 4 pe0 1 extal v ddx pucr/pdpee down 5 vss 6 pe1 1 xtal v ddx pucr/pdpee down 7 test n.a. reset pin down 8 pj0 kwj0 pwm6 miso1 v ddx perj/ppsj up 9 pj1 kwj1 ioc6 mosi1 v ddx perj/ppsj up 10 pj2 kwj2 ioc7 sck1 v ddx perj/ppsj up 11 pj3 kwj3 pwm7 ss1 v ddx perj/ppsj up 12 bkgd modc v ddx pucr/bkpue up 13 pp0 kwp0 etrig0 api_extclk pwm0 v ddx perp/ppsp disabled 14 pp1 kwp1 etrig1 eclkx2 pwm1 v ddx perp/ppsp disabled 15 pp2 kwp2 etrig2 pwm2 v ddx perp/ppsp disabled 16 pp3 kwp3 etrig3 pwm3 v ddx perp/ppsp disabled 17 pp4 kwp4 pwm4 v ddx perp/ppsp disabled 18 pp5 kwp5 pwm5 v ddx perp/ppsp disabled 19 pt5 ioc5 v ddx pert/ppst disabled 20 pt4 ioc4 v ddx pert/ppst disabled 21 pt3 ioc3 v ddx pert/ppst disabled 22 pt2 ioc2 v ddx pert/ppst disabled 23 pt1 ioc1 irq v ddx pert/ppst disabled 24 pt0 ioc0 xirq v ddx pert/ppst disabled 25 pad0 kwad0 an0 v dda per1ad/pps1ad disabled 26 pad8 kwad8 an8 v dda per0ad/pps0ad disabled 27 pad1 kwad1 an1 v dda per1ad/pps1ad disabled 28 pad9 kwad9 an9 v dda per0ad/pps0ad disabled 29 pad2 kwad2 an2 v dda per1ad/pps1ad disabled 30 pad10 kwad10 an10 dacu1 amp1 v dda per0ad/pps0ad disabled table 1-29. 48-pin lqfp pinout for s12ga192 and s12ga240 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 135 31 pad3 kwad3 an3 v dda per1ad/pps1ad disabled 32 pad11 kwad11 an11 dacu0 amp0 v dda per0ad/pps0ad disabled 33 pad4 kwad4 an4 v dda per1ad/pps1ad disabled 34 pad5 kwad5 an5 v dda per1ad/pps0ad disabled 35 pad6 kwad6 an6 v dda per1ad/pps1ad disabled 36 pad7 kwad7 an7 v dda per1ad/pps1ad disabled 37 vdda vrh 38 vssa 39 ps0 rxd0 v ddx pers/ppss up 40 ps1 txd0 v ddx pers/ppss up 41 ps2 rxd1 v ddx pers/ppss up 42 ps3 txd1 v ddx pers/ppss up 43 ps4 miso0 v ddx pers/ppss up 44 ps5 mosi0 v ddx pers/ppss up 45 ps6 sck0 v ddx pers/ppss up 46 ps7 api_extclk eclk ss0 v ddx pers/ppss up 47 pm0 rxd2 rxcan v ddx perm/ppsm disabled 48 pm1 txd2 txcan v ddx perm/ppsm disabled 1 the regular i/o characteristics (see section a.2, ?/o characteristics ) apply if the extal/xtal function is disabled table 1-29. 48-pin lqfp pinout for s12ga192 and s12ga240 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 136 freescale semiconductor 1.8.9.2 pinout 64-pin lqfp figure 1-25. 64-pin lqfp pinout for s12ga192 and s12ga240 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 s12ga192 s12ga240 64-pin lqfp pwm0/api_extclk/etrig0/kwp0/pp0 pwm1/eclkx2/etrig1/kwp1/pp1 pwm2/etrig2/kwp2/pp2 pwm3/etrig3/kwp3/pp3 pwm4/kwp4/pp4 pwm5/kwp5/pp5 pwm6/kwp6/pp6 pwm7/kwp7/pp7 ioc7/pt7 ioc6/pt6 ioc5/pt5 ioc4/pt4 ioc3/pt3 ioc2/pt2 irq/ioc1/pt1 xirq/ioc0/pt0 sck2/kwj6/pj6 mosi2/kwj5/pj5 miso2/kwj4/pj4 reset vddx vddr vssx extal/pe0 vss xtal/pe1 test miso1/kwj0/pj0 mosi1/kwj1/pj1 sck1/kwj2/pj2 ss1/kwj3/pj3 bkgd pj7/kwj7/ ss2 pm3/txd2 pm2/rxd2 pm1/txcan pm0/rxcan ps7/api_extclk/eclk/ ss0 ps6/sck0 ps5/mosi0 ps4/miso0 ps3/txd1 ps2/rxd1 ps1/txd0 ps0/rxd0 vssa vdda vrh pad15/kwad15/an15/dacu0 pad7/kwad7/an7 pad14/kwad14/an14/ampp0 pad6/kwad6/an6 pad13/kwad13/an13/ampm0 pad5/kwad5/an5 pad12/kwad12/an12 pad4/kwad4/an4 pad11/kwad11/an11/amp0 pad3/kwad3/an3 pad10/kwad10/an10/dacu1/amp1 pad2/kwad2/an2 pad9/kwad9/an9 pad1/kwad1/an1 pad8/kwad8/an8 pad0/kwad0/an0
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 137 table 1-30. 64-pin lqfp pinout for s12ga192 and s12ga240 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state 1 pj6 kwj6 sck2 v ddx perj/ppsj up 2 pj5 kwj5 mosi2 v ddx perj/ppsj up 3 pj4 kwj4 miso2 v ddx perj/ppsj up 4 reset v ddx pullup 5 vddx 6 vddr 7 vssx 8 pe0 1 extal v ddx pucr/pdpee down 9 vss 10 pe1 1 xtal v ddx pucr/pdpee down 11 test n.a. reset pin down 12 pj0 kwj0 miso1 v ddx perj/ppsj up 13 pj1 kwj1 mosi1 v ddx perj/ppsj up 14 pj2 kwj2 sck1 v ddx perj/ppsj up 15 pj3 kwj3 ss1 v ddx perj/ppsj up 16 bkgd modc v ddx pucr/bkpue up 17 pp0 kwp0 etrig0 api_extclk pwm0 v ddx perp/ppsp disabled 18 pp1 kwp1 etrig1 eclkx2 pwm1 v ddx perp/ppsp disabled 19 pp2 kwp2 etrig2 pwm2 v ddx perp/ppsp disabled 20 pp3 kwp3 etrig3 pwm3 v ddx perp/ppsp disabled 21 pp4 kwp4 pwm4 v ddx perp/ppsp disabled 22 pp5 kwp5 pwm5 v ddx perp/ppsp disabled 23 pp6 kwp6 pwm6 v ddx perp/ppsp disabled 24 pp7 kwp7 pwm7 v ddx perp/ppsp disabled 25 pt7 ioc7 v ddx pert/ppst disabled 26 pt6 ioc6 v ddx pert/ppst disabled 27 pt5 ioc5 v ddx pert/ppst disabled
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 138 freescale semiconductor 28 pt4 ioc4 v ddx pert/ppst disabled 29 pt3 ioc3 v ddx pert/ppst disabled 30 pt2 ioc2 v ddx pert/ppst disabled 31 pt1 ioc1 irq v ddx pert/ppst disabled 32 pt0 ioc0 xirq v ddx pert/ppst disabled 33 pad0 kwad0 an0 v dda per1ad/pps1ad disabled 34 pad8 kwad8 an8 v dda per0ad/pps0ad disabled 35 pad1 kwad1 an1 v dda per1ad/pps1ad disabled 36 pad9 kwad9 an9 v dda per0adpps0ad disabled 37 pad2 kwad2 an2 v dda per1ad/pps1ad disabled 38 pad10 kwad10 an10 dacu1 amp1 v dda per0ad/pps0ad disabled 39 pad3 kwad3 an3 v dda per1ad/pps1ad disabled 40 pad11 kwad11 an11 amp0 v dda per0ad/pps0ad disabled 41 pad4 kwad4 an4 v dda per1ad/pps1ad disabled 42 pad12 kwad12 an12 v dda per0ad/pps0ad disabled 43 pad5 kwad5 an5 v dda per1ad/pps1ad disabled 44 pad13 kwad13 an13 ampm0 v dda per0ad/pps0ad disabled 45 pad6 kwad6 an6 v dda per1ad/pps1ad disabled 46 pad14 kwad14 an14 ampp0 v dda per0ad/pps0ad disabled 47 pad7 kwad7 an7 v dda per1ad/pps1ad disabled 48 pad15 kwad15 an15 dacu0 v dda per0ad/pps0ad disabled 49 vrh 50 vdda 51 vssa 52 ps0 rxd0 v ddx pers/ppss up 53 ps1 txd0 v ddx pers/ppss up 54 ps2 rxd1 v ddx pers/ppss up 55 ps3 txd1 v ddx pers/ppss up 56 ps4 miso0 v ddx pers/ppss up table 1-30. 64-pin lqfp pinout for s12ga192 and s12ga240 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 139 57 ps5 mosi0 v ddx pers/ppss up 58 ps6 sck0 v ddx pers/ppss up 59 ps7 api_extclk eclk ss0 v ddx pers/ppss up 60 pm0 rxcan v ddx perm/ppsm disabled 61 pm1 txcan v ddx perm/ppsm disabled 62 pm2 rxd2 v ddx perm/ppsm disabled 63 pm3 txd2 v ddx perm/ppsm disabled 64 pj7 kwj7 ss2 v ddx perj/ppsj up 1 the regular i/o characteristics (see section a.2, ?/o characteristics ) apply if the extal/xtal function is disabled table 1-30. 64-pin lqfp pinout for s12ga192 and s12ga240 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func 5th func ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 140 freescale semiconductor 1.8.9.3 pinout 100-pin lqfp figure 1-26. 100-pin lqfp pinout for s12ga192 and s12ga240 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 vrh pc7/dacu1 pc6/ampp1 pc5/ampm1 pc4 pad15/kwad15/an15/dacu0 pad7/kwad7/an7 pad14/kwad14/an14/ampp0 pad6/kwad6/an6 pad13/kwad13/an13/ampm0 pad5/kwad5/an5 pad12/kwad12/an12 pad4/kwad4/an4 pad11/kwad11/an11/amp0 pad3/kwad3/an3 pad10/kwad10/an10/amp1 pad2/kwad2/an2 pad9/kwad9/an9 pad1/kwad1/an1 pad8/kwad8/an8 pad0/kwad0/an0 pc3 pc2 pc1 pc0 api_extclk/pb1 eclkx2/pb2 pb3 pwm0/etrig0/kwp0/pp0 pwm1/etrig1/kwp1/pp1 pwm2/etrig2/kwp2/pp2 pwm3/etrig3/kwp3/pp3 pwm4/kwp4/pp4 pwm5/kwp5/pp5 pwm6/kwp6/pp6 pwm7/kwp7/pp7 vddx3 vssx3 ioc7/pt7 ioc6/pt6 ioc5/pt5 ioc4/pt4 ioc3/pt3 ioc2/pt2 ioc1/pt1 ioc0/pt0 irq/pb4 xirq/pb5 pb6 pb7 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 sck2/kwj6/pj6 mosi2/kwj5/pj5 miso2/kwj4/pj4 pa 0 pa 1 pa 2 pa 3 reset vddx1 vddr vssx1 extal/pe0 vss xtal/pe1 test pa 4 pa 5 pa 6 pa 7 miso1/kwj0/pj0 mosi1/kwj1/pj1 sck1/kwj2/pj2 ss1/kwj3/pj3 bkgd eclk/pb0 pj7/kwj7/ ss2 pm3/txd2 pm2/rxd2 pd7 pd6 pd5 pd4 pm1/txcan pm0/rxcan vddx2 vssx2 ps7/api_extclk/ ss0 ps6/sck0 ps5/mosi0 ps4/miso0 ps3/txd1 ps2/rxd1 ps1/txd0 ps0/rxd0 pd3 pd2 pd1 pd0 vssa vdda s12ga192 s12ga240 100-pin lqfp
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 141 table 1-31. 100-pin lqfp pinout for s12ga192 and s12ga240 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func. ctrl reset state 1 pj6 kwj6 sck2 v ddx perj/ppsj up 2 pj5 kwj5 mosi2 v ddx perj/ppsj up 3 pj4 kwj4 miso2 v ddx perj/ppsj up 4 pa0v ddx pucr/pupae disabled 5 pa1v ddx pucr/pupae disabled 6 pa2v ddx pucr/pupae disabled 7 pa3v ddx pucr/pupae disabled 8 reset v ddx pullup 9 vddx1 10 vddr 11 vssx1 12 pe0 1 extal v ddx pucr/pdpee down 13 vss 14 pe1 1 xtal v ddx pucr/pdpee down 15 test n.a. reset pin down 16pa4v ddx pucr/pupae disabled 17pa5v ddx pucr/pupae disabled 18pa6v ddx pucr/pupae disabled 19pa7v ddx pucr/pupae disabled 20 pj0 kwj0 miso1 v ddx perj/ppsj up 21 pj1 kwj1 mosi1 v ddx perj/ppsj up 22 pj2 kwj2 sck1 v ddx perj/ppsj up 23 pj3 kwj3 ss1 v ddx perj/ppsj up 24 bkgd modc v ddx pucr/bkpue up 25 pb0 eclk v ddx pucr/pupbe disabled 26 pb1 api_extclk v ddx pucr/pupbe disabled 27 pb2 eclkx2 v ddx pucr/pupbe disabled
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 142 freescale semiconductor 28 pb3 v ddx pucr/pupbe disabled 29 pp0 kwp0 etrig0 pwm0 v ddx perp/ppsp disabled 30 pp1 kwp1 etrig1 pwm1 v ddx perp/ppsp disabled 31 pp2 kwp2 etrig2 pwm2 v ddx perp/ppsp disabled 32 pp3 kwp3 etrig3 pwm3 v ddx perp/ppsp disabled 33 pp4 kwp4 pwm4 v ddx perp/ppsp disabled 34 pp5 kwp5 pwm5 v ddx perp/ppsp disabled 35 pp6 kwp6 pwm6 v ddx perp/ppsp disabled 36 pp7 kwp7 pwm7 v ddx perp/ppsp disabled 37 vddx3 38 vssx3 39 pt7 ioc7 v ddx pert/ppst disabled 40 pt6 ioc6 v ddx pert/ppst disabled 41 pt5 ioc5 v ddx pert/ppst disabled 42 pt4 ioc4 v ddx pert/ppst disabled 43 pt3 ioc3 v ddx pert/ppst disabled 44 pt2 ioc2 v ddx pert/ppst disabled 45 pt1 ioc1 v ddx pert/ppst disabled 46 pt0 ioc0 v ddx pert/ppst disabled 47 pb4 irq v ddx pucr/pupbe disabled 48 pb5 xirq v ddx pucr/pupbe disabled 49 pb6 v ddx pucr/pupbe disabled 50 pb7 v ddx pucr/pupbe disabled 51 pc0 v dda pucr/pupce disabled 52 pc1 v dda pucr/pupce disabled 53 pc2 v dda pucr/pupce disabled 54 pc3 v dda pucr/pupce disabled 55 pad0 kwad0 an0 v dda per1ad/pps1ad disabled 56 pad8 kwad8 an8 v dda per0ad/pps0ad disabled table 1-31. 100-pin lqfp pinout for s12ga192 and s12ga240 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func. ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 143 57 pad1 kwad1 an1 v dda per1ad/pps1ad disabled 58 pad9 kwad9 an9 v dda per0ad/pps0ad disabled 59 pad2 kwad2 an2 v dda per1ad/pps1ad disabled 60 pad10 kwad10 an10 amp1 v dda per0ad/pps0ad disabled 61 pad3 kwad3 an3 v dda per1ad/pps1ad disabled 62 pad11 kwad11 an11 amp0 v dda per0ad/pps0ad disabled 63 pad4 kwad4 an4 v dda per1ad/pps1ad disabled 64 pad12 kwad12 an12 v dda per0ad/pps0ad disabled 65 pad5 kwad5 an5 v dda per1ad/pps1ad disabled 66 pad13 kwad13 an13 ampm0 v dda per0ad/pps0ad disabled 67 pad6 kwad6 an6 v dda per1ad/pps1ad disabled 68 pad14 kwad14 an14 ampp0 v dda per0ad/pps0ad disabled 69 pad7 kwad7 an7 v dda per1ad/pps1ad disabled 70 pad15 kwad15 an15 dacu0 v dda per0ad/pps0ad disabled 71 pc4 v dda pucr/pupce disabled 72 pc5 ampm1 v dda pucr/pupce disabled 73 pc6 ampp1 v dda pucr/pupce disabled 74 pc7 dacu1 v dda pucr/pupce disabled 75 vrh 76 vdda 77 vssa 78 pd0 v ddx pucr/pupde disabled 79 pd1 v ddx pucr/pupde disabled 80 pd2 v ddx pucr/pupde disabled 81 pd3 v ddx pucr/pupde disabled 82 ps0 rxd0 v ddx pers/ppss up 83 ps1 txd0 v ddx pers/ppss up 84 ps2 rxd1 v ddx pers/ppss up 85 ps3 txd1 v ddx pers/ppss up table 1-31. 100-pin lqfp pinout for s12ga192 and s12ga240 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func. ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 144 freescale semiconductor 86 ps4 miso0 v ddx pers/ppss up 87 ps5 mosi0 v ddx pers/ppss up 88 ps6 sck0 v ddx pers/ppss up 89 ps7 api_extclk ss0 v ddx pers/ppss up 90 vssx2 91 vddx2 92 pm0 rxcan v ddx perm/ppsm disabled 93 pm1 txcan v ddx perm/ppsm disabled 94 pd4 v ddx pucr/pupde disabled 95 pd5 v ddx pucr/pupde disabled 96 pd6 v ddx pucr/pupde disabled 97 pd7 v ddx pucr/pupde disabled 98 pm2 rxd2 v ddx perm/ppsm disabled 99 pm3 txd2 v ddx perm/ppsm disabled 100 pj7 kwj7 ss2 v ddx perj/ppsj up 1 the regular i/o characteristics (see section a.2, ?/o characteristics ) apply if the extal/xtal function is disabled table 1-31. 100-pin lqfp pinout for s12ga192 and s12ga240 function <----lowest-----priority-----highest----> power supply internal pull resistor package pin pin 2nd func. 3rd func. 4th func. ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 145 1.8.9.4 known good die option (kgd) table 1-32. kgd option for s12ga192 and s12ga240 function <----lowest-----priority-----highest----> power supply internal pull resistor wire bond die pad pin 2nd func. 3rd func. 4th func. ctrl reset state 1 pj6 kwj6 sck2 v ddx perj/ppsj up 2 pj5 kwj5 mosi2 v ddx perj/ppsj up 3 pj4 kwj4 miso2 v ddx perj/ppsj up 4 pa0v ddx pucr/pupae disabled 5 pa1v ddx pucr/pupae disabled 6 pa2v ddx pucr/pupae disabled 7 pa3v ddx pucr/pupae disabled 8 reset v ddx pullup 9 vddx1 10 vddr 11 vssx1 12 pe0 1 extal v ddx pucr/pdpee down 13 vss 14 pe1 1 xtal v ddx pucr/pdpee down 15 test n.a. reset pin down 16pa4v ddx pucr/pupae disabled 17pa5v ddx pucr/pupae disabled 18pa6v ddx pucr/pupae disabled 19pa7v ddx pucr/pupae disabled 20 pj0 kwj0 miso1 v ddx perj/ppsj up 21 pj1 kwj1 mosi1 v ddx perj/ppsj up 22 pj2 kwj2 sck1 v ddx perj/ppsj up 23 pj3 kwj3 ss1 v ddx perj/ppsj up 24 bkgd modc v ddx pucr/bkpue up 25 pb0 eclk v ddx pucr/pupbe disabled 26 pb1 api_extclk v ddx pucr/pupbe disabled 27 pb2 eclkx2 v ddx pucr/pupbe disabled
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 146 freescale semiconductor 28 pb3 v ddx pucr/pupbe disabled 29 pp0 kwp0 etrig0 pwm0 v ddx perp/ppsp disabled 30 pp1 kwp1 etrig1 pwm1 v ddx perp/ppsp disabled 31 pp2 kwp2 etrig2 pwm2 v ddx perp/ppsp disabled 32 pp3 kwp3 etrig3 pwm3 v ddx perp/ppsp disabled 33 pp4 kwp4 pwm4 v ddx perp/ppsp disabled 34 pp5 kwp5 pwm5 v ddx perp/ppsp disabled 35 pp6 kwp6 pwm6 v ddx perp/ppsp disabled 36 pp7 kwp7 pwm7 v ddx perp/ppsp disabled 37 vddx3 38 vssx3 39 pt7 ioc7 v ddx pert/ppst disabled 40 pt6 ioc6 v ddx pert/ppst disabled 41 pt5 ioc5 v ddx pert/ppst disabled 42 pt4 ioc4 v ddx pert/ppst disabled 43 pt3 ioc3 v ddx pert/ppst disabled 44 pt2 ioc2 v ddx pert/ppst disabled 45 pt1 ioc1 v ddx pert/ppst disabled 46 pt0 ioc0 v ddx pert/ppst disabled 47 pb4 irq v ddx pucr/pupbe disabled 48 pb5 xirq v ddx pucr/pupbe disabled 49 pb6 v ddx pucr/pupbe disabled 50 pb7 v ddx pucr/pupbe disabled 51 pc0 v dda pucr/pupce disabled 52 pc1 v dda pucr/pupce disabled 53 pc2 v dda pucr/pupce disabled 54 pc3 v dda pucr/pupce disabled 55 pad0 kwad0 an0 v dda per1ad/pps1ad disabled 56 pad8 kwad8 an8 v dda per0ad/pps0ad disabled table 1-32. kgd option for s12ga192 and s12ga240 function <----lowest-----priority-----highest----> power supply internal pull resistor wire bond die pad pin 2nd func. 3rd func. 4th func. ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 147 57 pad1 kwad1 an1 v dda per1ad/pps1ad disabled 58 pad9 kwad9 an9 v dda per0ad/pps0ad disabled 59 pad2 kwad2 an2 v dda per1ad/pps1ad disabled 60 pad10 kwad10 an10 amp1 v dda per0ad/pps0ad disabled 61 pad3 kwad3 an3 v dda per1ad/pps1ad disabled 62 pad11 kwad11 an11 amp0 v dda per0ad/pps0ad disabled 63 pad4 kwad4 an4 v dda per1ad/pps1ad disabled 64 pad12 kwad12 an12 v dda per0ad/pps0ad disabled 65 pad5 kwad5 an5 v dda per1ad/pps1ad disabled 66 pad13 kwad13 an13 ampm0 v dda per0ad/pps0ad disabled 67 pad6 kwad6 an6 v dda per1ad/pps1ad disabled 68 pad14 kwad14 an14 ampp0 v dda per0ad/pps0ad disabled 69 pad7 kwad7 an7 v dda per1ad/pps1ad disabled 70 pad15 kwad15 an15 dacu0 v dda per0ad/pps0ad disabled 71 pc4 v dda pucr/pupce disabled 72 pc5 ampm1 v dda pucr/pupce disabled 73 pc6 ampp1 v dda pucr/pupce disabled 74 pc7 dacu1 v dda pucr/pupce disabled 75 vrh 76 vdda 77 vssa 78 pd0 v ddx pucr/pupde disabled 79 pd1 v ddx pucr/pupde disabled 80 pd2 v ddx pucr/pupde disabled 81 pd3 v ddx pucr/pupde disabled 82 ps0 rxd0 v ddx pers/ppss up 83 ps1 txd0 v ddx pers/ppss up 84 ps2 rxd1 v ddx pers/ppss up 85 ps3 txd1 v ddx pers/ppss up table 1-32. kgd option for s12ga192 and s12ga240 function <----lowest-----priority-----highest----> power supply internal pull resistor wire bond die pad pin 2nd func. 3rd func. 4th func. ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 148 freescale semiconductor 1.9 system clock description for the system clock description please refer to chapter chapter 1, ?evice overview mc9s12g-family . 1.10 modes of operation the mcu can operate in different modes. these are described in 1.10.1 chip con?uration summary . the mcu can operate in different power modes to facilitate power saving when full system performance is not required. these are described in 1.10.2 low power operation . some modules feature a software programmable option to freeze the module status whilst the background debug module is active to facilitate debugging. 1.10.1 chip con?uration summary the different modes and the security state of the mcu affect the debug features (enabled or disabled). 86 ps4 miso0 v ddx pers/ppss up 87 ps5 mosi0 v ddx pers/ppss up 88 ps6 sck0 v ddx pers/ppss up 89 ps7 api_extclk ss0 v ddx pers/ppss up 90 vssx2 91 vddx2 92 pm0 rxcan v ddx perm/ppsm disabled 93 pm1 txcan v ddx perm/ppsm disabled 94 pd4 v ddx pucr/pupde disabled 95 pd5 v ddx pucr/pupde disabled 96 pd6 v ddx pucr/pupde disabled 97 pd7 v ddx pucr/pupde disabled 98 pm2 rxd2 v ddx perm/ppsm disabled 99 pm3 txd2 v ddx perm/ppsm disabled 100 pj7 kwj7 ss2 v ddx perj/ppsj up 1 the regular i/o characteristics (see section a.2, ?/o characteristics ) apply if the extal/xtal function is disabled table 1-32. kgd option for s12ga192 and s12ga240 function <----lowest-----priority-----highest----> power supply internal pull resistor wire bond die pad pin 2nd func. 3rd func. 4th func. ctrl reset state
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 149 the operating mode out of reset is determined by the state of the modc signal during reset (see table 1-33 ). the modc bit in the mode register shows the current operating mode and provides limited mode switching during operation. the state of the modc signal is latched into this bit on the rising edge of reset. 1.10.1.1 normal single-chip mode this mode is intended for normal device operation. the opcode from the on-chip memory is being executed after reset (requires the reset vector to be programmed correctly). the processor program is executed from internal memory. 1.10.1.2 special single-chip mode this mode is used for debugging single-chip operation, boot-strapping, or security related operations. the background debug module bdm is active in this mode. the cpu executes a monitor program located in an on-chip rom. bdm ?mware waits for additional serial commands through the bkgd pin. 1.10.2 low power operation the mc9s12g has two static low-power modes pseudo stop and stop mode. for a detailed description refer to s12cpmu section. 1.11 security the mcu security mechanism prevents unauthorized access to the flash memory. refer to chapter 9, ?ecurity (s12xs9secv2) , section 7.4.1, ?ecurity , and section 29.5, ?ecurity . 1.12 resets and interrupts consult the s12 cpu manual and the s12sint section for information on exception processing. 1.12.1 resets table 1-34. lists all reset sources and the vector locations. resets are explained in detail in the chapter 10, ?12 clock, reset and power management unit (s12cpmu) . table 1-33. chip modes chip modes modc normal single chip 1 special single chip 0
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 150 freescale semiconductor table 1-34. reset sources and vector locations 1.12.2 interrupt vectors table 1-35 lists all interrupt sources and vectors in the default order of priority. the interrupt module (see chapter 6, ?nterrupt module (s12sintv1) ) provides an interrupt vector base register (ivbr) to relocate the vectors. vector address reset source ccr mask local enable $fffe power-on reset (por) none none $fffe low voltage reset (lvr) none none $fffe external pin reset none none $fffe illegal address reset none none $fffc clock monitor reset none osce bit in cpmuosc register $fffa cop watchdog reset none cr[2:0] in cpmucop register table 1-35. interrupt vector locations (sheet 1 of 2) vector address 1 interrupt source ccr mask local enable wake up from stop wakeup from wait vector base + $f8 unimplemented instruction trap none none - - vector base+ $f6 swi none none - - vector base+ $f4 xirq x bit none yes yes vector base+ $f2 irq i bit irqcr (irqen) yes yes vector base+ $f0 rti time-out interrupt i bit cpmuint (rtie) 10.6 interrupts vector base+ $ee tim timer channel 0 i bit tie (c0i) no yes vector base + $ec tim timer channel 1 i bit tie (c1i) no yes vector base+ $ea tim timer channel 2 i bit tie (c2i) no yes vector base+ $e8 tim timer channel 3 i bit tie (c3i) no yes vector base+ $e6 tim timer channel 4 i bit tie (c4i) no yes vector base+ $e4 tim timer channel 5 i bit tie (c5i) no yes vector base + $e2 tim timer channel 6 i bit tie (c6i) no yes vector base+ $e0 tim timer channel 7 i bit tie (c7i) no yes vector base+ $de tim timer over?w i bit tscr2 (toi) no yes vector base+ $dc tim pulse accumulator a over?w 2 i bit pactl (paovi) no yes vector base + $da tim pulse accumulator input edge 3 i bit pactl (pai) no yes vector base + $d8 spi0 i bit spi0cr1 (spie, sptie) no yes vector base+ $d6 sci0 i bit sci0cr2 (tie, tcie, rie, ilie) ye s ye s vector base + $d4 sci1 i bit sci1cr2 (tie, tcie, rie, ilie) ye s ye s
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 151 vector base + $d2 adc i bit atdctl2 (ascie) no yes vector base + $d0 reserved vector base + $ce port j i bit piej (piej7-piej0) yes yes vector base + $cc acmp i bit acmpc (acie) no yes vector base + $ca reserved vector base + $c8 oscillator status interrupt i bit cpmuint (oscie) no yes vector base + $c6 pll lock interrupt i bit cpmuint (lockie) no yes vector base + $c4 reserved vector base + $c2 sci2 i bit sci2cr2 (tie, tcie, rie, ilie) ye s ye s vector base + $c0 reserved vector base + $be spi1 i bit spi1cr1 (spie, sptie) no yes vector base + $bc spi2 i bit spi2cr1 (spie, sptie) no yes vector base + $ba flash error i bit fercnfg (sfdie, dfdie) no no vector base + $b8 flash command i bit fcnfg (ccie) no yes vector base + $b6 can wake-up i bit canrier (wupie) yes yes vector base + $b4 can errors i bit canrier (cscie, ovrie) no yes vector base + $b2 can receive i bit canrier (rxfie) no yes vector base + $b0 can transmit i bit cantier (txeie[2:0]) no yes vector base + $ae to vector base + $90 reserved vector base + $8e port p interrupt i bit piep (piep7-piep0) yes yes vector base+ $8c reserved vector base + $8a low-voltage interrupt (lvi) i bit cpmuctrl (lvie) no yes vector base + $88 autonomous periodical interrupt (api) i bit cpmuapictrl (apie) yes yes vector base + $86 reserved vector base + $84 adc compare interrupt i bit atdctl2 (acmpie) no yes vector base + $82 port ad interrupt i bit pie1ad(pie1ad7-pie1ad0) pie0ad(pie0ad7-pie0ad0) ye s ye s vector base + $80 spurious interrupt none - - 1 16 bits vector address based 2 only available if the 8 channel timer module is instantiated on the device 3 only available if the 8 channel timer module is instantiated on the device table 1-35. interrupt vector locations (sheet 2 of 2) vector address 1 interrupt source ccr mask local enable wake up from stop wakeup from wait
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 152 freescale semiconductor 1.12.3 effects of reset when a reset occurs, mcu registers and control bits are initialized. refer to the respective block sections for register reset states. on each reset, the flash module executes a reset sequence to load flash con?uration registers. 1.12.3.1 flash con?uration reset sequence phase on each reset, the flash module holds cpu activity while loading flash module registers from the flash memory. if double faults are detected in the reset phase, flash module protection and security may be active on leaving reset. this is explained in more detail in the flash module section 29.1, ?ntroduction . 1.12.3.2 reset while flash command active if a reset occurs while any flash command is in progress, that command will be immediately aborted. the state of the word being programmed or the sector/block being erased is not guaranteed. 1.12.3.3 i/o pins refer to the pim section for reset con?urations of all peripheral module ports. 1.12.3.4 ram the ram arrays are not initialized out of reset. 1.13 cop con?uration the cop time-out rate bits cr[2:0] and the wcop bit in the cpmucop register at address 0x003c are loaded from the flash register fopt. see table 1-36 and table 1-37 for coding. the fopt register is loaded from the flash con?uration ?ld byte at global address 0x3_ff0e during the reset sequence. table 1-36. initial cop rate con?uration nv[2:0] in fopt register cr[2:0] in cpmucop register 000 111 001 110 010 101 011 100 100 011 101 010 110 001 111 000
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 153 1.14 autonomous clock (aclk) con?uration the autonomous clock 1 (aclk) is not factory trimmed. the reset value of the autonomous clock trimming register 2 (cpmuaclktr) is 0xfc. 1.15 adc external trigger input connection the adc module includes external trigger inputs etrig0, etrig1, etrig2, and etrig3. the external trigger allows the user to synchronize adc conversion to external trigger events. chapter 2, ?ort integration module (s12gpimv0) describes the connection of the external trigger inputs. consult the adc section for information about the analog-to-digital converter module. references to freeze mode are equivalent to active bdm mode. 1.16 adc special conversion channels whenever the adcs special channel conversion bit (sc) is set, it is capable of running conversion on a number of internal channels (see table 13-15 ). table 1-38 lists the internal reference voltages which are connected to these special conversion channels. table 1-37. initial wcop con?uration nv[3] in fopt register wcop in cpmucop register 10 01 1. see chapter 10, ?12 clock, reset and power management unit (s12cpmu) 2. see section 10.3.2.15, ?utonomous clock trimming register (cpmuaclktr) table 1-38. usage of adc special conversion channels adc channel usage internal_0 v ddf 1 1 see section 1.17, ?dc result reference . internal_1 unused internal_2 unused internal_3 unused internal_4 unused internal_5 unused internal_6 unused temperature sense of adc hardmacro 2 2 the adc temperature sensor is only available on s12ga192 and s12ga240 devices. internal_7 unused
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 154 freescale semiconductor 1.17 adc result reference mcus of the s12g-family are able to measure the internal reference voltage v ddf (see table 1-38 ). v ddf is a constant voltage with a narrow distribution over temperature and external voltage supply (see table a-43 ). a 12-bit left justi?d 1 adc conversion result of v ddf is provided at address 0x0_4022/0x0_4023 in the nvms ifr for reference.the measurement conditions of the reference conversion are listed in section a.16, adc conversion result reference . by measuring the voltage v ddf (see table 1-38 ) and comparing the result to the reference value in the ifr, it is possible to determine the adcs reference voltage v rh in the application environment: the exact absolute value of an analog conversion can be determined as follows: with: convertedadinput: result of the analog to digital conversion of the desired pin convertedreference: result of channel ?nternal_0?conversion storedreference: value in ifr locatio 0x0_4022/0x0_4023 n: adc resolution (10 bit) caution to assure high accuracy of the v ddf reference conversion, the nvms must not be programmed, erased, or read while the conversion takes place. this implies that code must be executed from ram. the ?onvertedreference value must be the average of eight consecutive conversions. caution the adcs reference voltage v rh must remain at a constant level throughout the conversion process. 1.18 adc vrh/vrl signal connection on all s12g devices except for the s12ga192 and the s12ga240 the external vrh signal is directly connected to the adcs vrh signal input. the adcs vrl input is connected to vssa. (see figure 1-27 ). 1. the format of the stored v ddf reference value is still subject to change. v rh storedreference convertedreference ------------------------------------------------------------ - 5v ? = result convertedadinput storedreference 5v ? convertedreference 2 n ? ------------------------------------------------------------------------ - ? =
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 freescale semiconductor 155 the s12ga192 and the s12ga240 contain a reference voltage attenuator (rva) module. the connection of the adcs vrh/vrl inputs on these devices is shown in figure 1-27 . figure 1-27. adc vrh/vrl signal connection 1.19 bdm clock source connectivity the bdm clock is mapped to the vco clock divided by four. adc vrh vrl vrh vssa s12gn16, s12gna16, s12gn32, s12gna32, s12gn48, s12g48, s12ga48, s12g64, s12ga64, s12g96, s12ga96, s12g128, s12ga128, s12g192, s12g240 adc rva vrh vrl vrh_int vrl_int vssa vrh vrh vssa s12ga192, s12ga240
device overview mc9s12g-family mc9s12g family reference manual, rev.1.23 156 freescale semiconductor
mc9s12g family reference manual, rev.1.23 freescale semiconductor 157 chapter 2 port integration module (s12gpimv1) revision history 2.1 introduction this section describes the s12g-family port integration module (pim) in its con?urations depending on the family devices in their available package options. it is split up into two parts, ?stly determining the routing of the various signals to the available package pins (?im routing? and secondly describing the general-purpose port related logic (?im ports?. 2.1.1 glossary table 2-1. glossary of terms rev. no. (item no.) date (submitted by) sections affected substantial change(s) v01.01 01 dec 2010 table 2-4 table 2-5 table 2-8 table 2-16 table 2-17 removed txd2 and rxd2 from pm1 and pm0 for g64 simpli?d input buffer control description on port c and ad corrected dac signal priorities on pins pad10 and pad11 with shared amp and dacu output functions v01.02 30 aug 2011 2.4.3.40/2-23 2 2.4.3.48/2-23 8 2.4.3.63/2-24 7 2.4.3.64/2-24 8 corrected pifx descriptions v01.03 15 mar 2012 table 2-2./2-1 58 table 2-4./2-1 62 added ga and gna derivatives term de?ition pin package terminal with a unique number de?ed in the device pinout section signal input or output line of a peripheral module or general-purpose i/o function arbitrating for a dedicated pin
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 158 freescale semiconductor 2.1.2 overview the pim establishes the interface between the peripheral modules and the i/o pins. it controls the electrical pin properties as well as the signal prioritization and multiplexing on shared pins. the family devices share same sets of package options (refer to device overview section) determining the availability of pins and the related pim memory maps. the corresponding devices are referenced throughout this section by their group name as shown in table 2-2 . 2.1.3 features the pim includes these distinctive registers: data registers and data direction registers for ports a, b, c, d, e, t, s, m, p, j and ad when used as general-purpose i/o control registers to enable/disable pull devices and select pullups/pulldowns on ports t, s, m, p, j and ad on per-pin basis single control register to enable/disable pull devices on ports a, b, c, d and e, on per-port basis and on bkgd pin control registers to enable/disable open-drain (wired-or) mode on ports s and m interrupt ?g register for pin interrupts on ports p, j and ad control register to con?ure irq pin operation routing register to support programmable signal redirection in 20 tssop only routing register to support programmable signal redirection in 100 lqfp package only package code register preset by factory related to package in use, writable once after reset. also includes bit to reprogram routing of api_extclk in all packages. port group of general-purpose i/o pins sharing peripheral signals table 2-2. device groups group devices with same set of package options g1 (100/64/48) s12g240, s12ga240 s12g192, s12ga192 s12g128, s12ga128 s12g96, s12ga96 g2 (64/48/32) s12g64, s12ga64 1 , s12g48, s12ga48 1 ,s12gn48 1 no 32 pin g3 (48/32/20) s12gn32, s12gna32 1,2 s12gn16, s12gna16 1,2 2 no 20 pin term de?ition
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 159 control register for free-running clock outputs a standard port pin has the following minimum features: input/output selection 3.15 v - 5 v digital and analog input input with selectable pullup or pulldown device optional features supported on dedicated pins: open drain for wired-or connections key-wakeup feature: external pin interrupt with glitch filtering, which can also be used for wakeup from stop mode. 2.1.4 block diagram figure 2-1. block diagram 2.2 pim routing - external signal description this section lists and describes the signals that do connect off-chip. table 2-3 shows the availability of i/o port pins for each group in the largest offered package option. table 2-3. port pin availability (in largest package) per device port device group g1 (100 pin) g2 (64 pin) g3 (48 pin) a 7-0 - - b 7-0 - - peripheral module pim ports pim routing 0 1 n pin #0 package code pin routing (20 tssop only) pin #n pin enable, data pin enable, data data data control control
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 160 freescale semiconductor 2.2.1 package code the availability of pins and the related peripheral signals are determined by a package code ( section 2.4.3.33, ?ackage code register (pkgcr) ?. the related value is loaded from a factory programmed non-volatile memory location into the register during the reset sequence. based on the package code all non-bonded pins will have the input buffer disabled to avoid shoot-through current resulting in excess current in stop mode. 2.2.2 prioritization if more than one output signal is attempted to be enabled on a speci? pin, a priority scheme determines the signal taking effect. general rules: the peripheral with the highest amount of pins has priority on the related pins when it is enabled. if a peripheral can selectively disable a function, the freed up pin is used with the next enabled peripheral signal. the general-purpose output function takes control if no peripheral function is enabled. input signals are not prioritized. therefore the input function remains active (for example timer input capture) even if a pin is used with the output signal of another peripheral or general-purpose output. 2.2.3 signals and priorities table 2-4 shows all pins with their related signals per device and package that are controlled by the pim. a signal name in squared brackets denotes the port register bit related to the digital i/o function of the pin (port register port/pt not listed). it is a representative for any other port related register bit with the same c 7-0 - - d 7-0 - - e 1-0 1-0 1-0 t 7-0 7-0 5-0 s 7-0 7-0 7-0 m 3-0 3-0 1-0 p 7-0 7-0 5-0 j 7-0 7-0 3-0 ad 15-0 15-0 11-0 table 2-3. port pin availability (in largest package) per device port device group g1 (100 pin) g2 (64 pin) g3 (48 pin)
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 161 index in pti, ddr, per, pps, and where applicable in pie, pif or wom (see section 2.4, ?im ports - memory map and register de?ition ?. for example pin pad15: signal [pt0ad7] is bit 7 of register pt0ad; other related register bits of this pin are pti0ad7, ddr0ad7, per0ad7, pps0ad7, pie0ad7 and pif0ad7. note if there is more than one signal associated with a pin, the priority is indicated by the position in the table from top (highest priority) to bottom (lowest priority).
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 162 freescale semiconductor 2.3 pim routing - functional description table 2-4. signals and priorities port pin signal signals per device and package (signal priority on pin from top to bottom) legend ga240 / ga192 g240 / g192 g128 / ga128 / g96 / ga96 ga240 / ga192 g240 / g192 g128 / ga128 / g96 / ga96 g64 / ga64 / g48 / ga48 gn48 ga240 / ga192 g240 / g192 g128 / ga128 / g96 / ga96 g64 / ga64 / g48 / ga48 gn48 gn32 / gna32 gn16 / gna16 g64 / g48 gn48 gn32 gn16 gn32 gn16 signal available on pin ? routing option on pin ? routing reset location not available on pin 100 64 48 32 20 i/o description - bkgd modc i modc input during reset bkgd i/o bdm communication a pa7-pa0 [pa7:pa0] i/o gpio b pb7-pb6 [pb7:pb6] i/o gpio pb5 xirq i non-maskable level-sensitive interrupt [pb5] i/o gpio pb4 irq i maskable level- or falling-edge sensitive interrupt [pb4] i/o gpio pb3 [pb3] i/o gpio pb2 eclkx2 o free-running clock (eclk x 2) [pb2] i/o gpio pb1 api_extclk ? ? ? o api clock [pb1] i/o gpio pb0 eclk o free-running clock [pb0] i/o gpio c pc7 dacu1 o dac1 output unbuffered [pc7] i/o gpio pc6 ampp1 i dac1 non-inv. input (+) [pc6] i/o gpio pc5 ampm1 i dac1 inverting input (-) [pc5] i/o gpio pc4-pc2 an15-an13 ? ? i adc analog [pc4:pc2] i/o gpio pc1-pc0 an11-an10 ? ? i adc analog [pc1:pc0] i/o gpio d pd7-pd0 [pd7:pd0] i/o gpio
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 163 e pe1 xtal - cpmu osc signal txd0 ? ? i/o sci transmit ioc3 ? ? i/o timer channel pwm1 o pwm channel etrig1 i adc external trigger [pe1] i/o gpio pe0 extal - cpmu osc signal rxd0 ? ? i sci receive ioc2 ? ? i/o timer channel pwm0 o pwm channel etrig0 i adc external trigger [pe0] i/o gpio t pt7-pt6 ioc7-ioc6 i/o timer channel [ptt7:ptt6] i/o gpio pt5 - pt4 ioc5-ioc4 i/o timer channel [ptt5:ptt4] i/o gpio pt3-pt2 ioc3-ioc2 i/o timer channel [ptt3:ptt2] i/o gpio pt1 irq i maskable level- or falling-edge sensitive interrupt ioc1 i/o timer channel [ptt1] i/o gpio pt0 xirq i non-maskable level-sensitive interrupt ioc0 i/o timer channel [ptt0] i/o gpio table 2-4. signals and priorities port pin signal signals per device and package (signal priority on pin from top to bottom) legend ga240 / ga192 g240 / g192 g128 / ga128 / g96 / ga96 ga240 / ga192 g240 / g192 g128 / ga128 / g96 / ga96 g64 / ga64 / g48 / ga48 gn48 ga240 / ga192 g240 / g192 g128 / ga128 / g96 / ga96 g64 / ga64 / g48 / ga48 gn48 gn32 / gna32 gn16 / gna16 g64 / g48 gn48 gn32 gn16 gn32 gn16 signal available on pin ? routing option on pin ? routing reset location not available on pin 100 64 48 32 20 i/o description
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 164 freescale semiconductor s ps7 ss0 i/o spi slave select txd0 ? ? i/o sci transmit pwm5 o pwm channel pwm3 ? ? o pwm channel eclk o free-running clock api_extclk ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? o api clock etrig3 ? ? i adc external trigger [pts7] i/o gpio ps6 sck0 i/o spi serial clock ioc5 i/o timer channel ioc3 ? ? i/o timer channel [pts6] i/o gpio ps5 mosi0 i/o spi master out/slave in ioc4 i/o timer channel ioc2 ? ? i/o timer channel [pts5] i/o gpio ps4 miso0 i/o spi master in/slave out rxd0 ? ? i sci receive pin pwm4 o pwm channel pwm2 ? ? o pwm channel etrig2 ? ? i adc external trigger [pts4] i/o gpio ps3 txd1 i/o sci transmit [pts3] i/o gpio ps2 rxd1 i sci receive [pts2] i/o gpio ps1 txd0 i/o sci transmit [pts1] i/o gpio ps0 rxd0 i sci receive [pts0] i/o gpio table 2-4. signals and priorities port pin signal signals per device and package (signal priority on pin from top to bottom) legend ga240 / ga192 g240 / g192 g128 / ga128 / g96 / ga96 ga240 / ga192 g240 / g192 g128 / ga128 / g96 / ga96 g64 / ga64 / g48 / ga48 gn48 ga240 / ga192 g240 / g192 g128 / ga128 / g96 / ga96 g64 / ga64 / g48 / ga48 gn48 gn32 / gna32 gn16 / gna16 g64 / g48 gn48 gn32 gn16 gn32 gn16 signal available on pin ? routing option on pin ? routing reset location not available on pin 100 64 48 32 20 i/o description
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 165 m pm3 txd2 i/o sci transmit [ptm3] i/o gpio pm2 rxd2 i sci receive [ptm2] i/o gpio pm1 txcan o mscan transmit txd2 i/o sci transmit txd1 i/o sci transmit [ptm1] i/o gpio pm0 rxcan i mscan receive rxd2 i sci receive rxd1 i sci receive [ptm0] i/o gpio table 2-4. signals and priorities port pin signal signals per device and package (signal priority on pin from top to bottom) legend ga240 / ga192 g240 / g192 g128 / ga128 / g96 / ga96 ga240 / ga192 g240 / g192 g128 / ga128 / g96 / ga96 g64 / ga64 / g48 / ga48 gn48 ga240 / ga192 g240 / g192 g128 / ga128 / g96 / ga96 g64 / ga64 / g48 / ga48 gn48 gn32 / gna32 gn16 / gna16 g64 / g48 gn48 gn32 gn16 gn32 gn16 signal available on pin ? routing option on pin ? routing reset location not available on pin 100 64 48 32 20 i/o description
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 166 freescale semiconductor p pp7-pp6 pwm7-pwm6 o pwm channel [ptp7:ptp6]/ kwp7-kwp6 i/o gpio with interrupt pp5-pp4 pwm5-pwm4 o pwm channel [ptp5:ptp4]/ kwp5-kwp4 i/o gpio with interrupt pp3-pp2 pwm3-pwm2 o pwm channel etrig3- etrig2 i adc external trigger [ptp3:ptp2]/ kwp3-kwp2 i/o gpio with interrupt pp1 pwm1 o pwm channel eclkx2 o free-running clock (eclk x 2) etrig1 i adc external trigger [ptp1]/ kwp1 i/o gpio with interrupt pp0 pwm0 o pwm channel api_extclk ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? o api clock etrig0 i adc external trigger [ptp0]/ kwp0 i/o gpio with interrupt table 2-4. signals and priorities port pin signal signals per device and package (signal priority on pin from top to bottom) legend ga240 / ga192 g240 / g192 g128 / ga128 / g96 / ga96 ga240 / ga192 g240 / g192 g128 / ga128 / g96 / ga96 g64 / ga64 / g48 / ga48 gn48 ga240 / ga192 g240 / g192 g128 / ga128 / g96 / ga96 g64 / ga64 / g48 / ga48 gn48 gn32 / gna32 gn16 / gna16 g64 / g48 gn48 gn32 gn16 gn32 gn16 signal available on pin ? routing option on pin ? routing reset location not available on pin 100 64 48 32 20 i/o description
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 167 j pj7 ss2 i/o spi slave select [ptj7]/ kwj7 i/o gpio with interrupt pj6 sck2 i/o spi serial clock [ptj6]/ kwj6 i/o gpio with interrupt pj5 mosi2 i/o spi master out/slave in [ptj5]/ kwj5 i/o gpio with interrupt pj4 miso2 i/o spi master in/slave out [ptj4]/ kwj4 i/o gpio with interrupt pj3 ss1 i/o spi slave select pwm7 o pwm channel [ptj3]/ kwj3 i/o gpio with interrupt pj2 sck1 i/o spi serial clock ioc7 i/o timer channel [ptj2]/ kwj2 i/o gpio with interrupt pj1 mosi1 i/o spi master out/slave in ioc6 i/o timer channel [ptj1]/ kwj1 i/o gpio with interrupt pj0 miso1 i/o spi master in/slave out pwm6 i/o timer channel [ptj0]/ kwj0 i/o gpio with interrupt table 2-4. signals and priorities port pin signal signals per device and package (signal priority on pin from top to bottom) legend ga240 / ga192 g240 / g192 g128 / ga128 / g96 / ga96 ga240 / ga192 g240 / g192 g128 / ga128 / g96 / ga96 g64 / ga64 / g48 / ga48 gn48 ga240 / ga192 g240 / g192 g128 / ga128 / g96 / ga96 g64 / ga64 / g48 / ga48 gn48 gn32 / gna32 gn16 / gna16 g64 / g48 gn48 gn32 gn16 gn32 gn16 signal available on pin ? routing option on pin ? routing reset location not available on pin 100 64 48 32 20 i/o description
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 168 freescale semiconductor ad pad15 dacu0 o dac0 output unbuffered an15 ? ? i adc analog [pt0ad7]/ kwad15 i/o gpio with interrupt pad14 ampp0 i dac0 non-inv. input (+) an14 ? ? i adc analog [pt0ad6]/ kwad14 i/o gpio with interrupt pad13 ampm0 i dac0 inverting input (-) an13 ? ? i adc analog [pt0ad5]/ kwad13 i/o gpio with interrupt pad12 an12 i adc analog [pt0ad4]/ kwad12 i/o gpio with interrupt pad11 amp0 o dac0 output buffered dacu0 o dac0 output unbuffered acmpm i acmp inverting input (-) an11 ? ? i adc analog [pt0ad3]/ kwad11 i/o gpio with interrupt pad10 amp1 o dac1 output buffered dacu1 o dac1 output unbuffered acmpp i acmp non-inv. input (+) an10 ? ? i adc analog [pt0ad2]/ kwad10 i/o gpio with interrupt pad9 acmpo o acmp unsync. dig. out an9 i adc analog [pt0ad1]/ kwad9 i/o gpio with interrupt pad8 an8 i adc analog [pt0ad0]/ kwad8 i/o gpio with interrupt table 2-4. signals and priorities port pin signal signals per device and package (signal priority on pin from top to bottom) legend ga240 / ga192 g240 / g192 g128 / ga128 / g96 / ga96 ga240 / ga192 g240 / g192 g128 / ga128 / g96 / ga96 g64 / ga64 / g48 / ga48 gn48 ga240 / ga192 g240 / g192 g128 / ga128 / g96 / ga96 g64 / ga64 / g48 / ga48 gn48 gn32 / gna32 gn16 / gna16 g64 / g48 gn48 gn32 gn16 gn32 gn16 signal available on pin ? routing option on pin ? routing reset location not available on pin 100 64 48 32 20 i/o description
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 169 ad pad7 acmpm i acmp inverting input (-) an7 i adc analog [pt1ad7]/ kwad7 i/o gpio with interrupt pad6 acmpp i acmp non-inv. input (+) an6 i adc analog [pt1ad6]/ kwad6 i/o gpio with interrupt pad5 acmpo o acmp unsync. dig. out acmpm i acmp inverting input (-) an5 i adc analog txd0 ? ? i/o sci transmit ioc3 ? ? i/o timer channel pwm3 ? ? o pwm channel etrig3 ? ? i adc external trigger [pt1ad5]/ kwad5 i/o gpio with interrupt pad4 acmpp i acmp non-inv. input (+) an4 i adc analog rxd0 ? ? i sci receive ioc2 ? ? i/o timer channel pwm2 ? ? o pwm channel etrig2 ? ? i adc external trigger [pt1ad4]/ kwad4 i/o gpio with interrupt pad3 acmpo o acmp unsync. dig. out an3 i adc analog [pt1ad3]/ kwad3 i/o gpio with interrupt pad2-pad0 an2-an0 i adc analog [pt1ad2: pt1ad0]/ kwad2- kwad0 i/o gpio with interrupt table 2-4. signals and priorities port pin signal signals per device and package (signal priority on pin from top to bottom) legend ga240 / ga192 g240 / g192 g128 / ga128 / g96 / ga96 ga240 / ga192 g240 / g192 g128 / ga128 / g96 / ga96 g64 / ga64 / g48 / ga48 gn48 ga240 / ga192 g240 / g192 g128 / ga128 / g96 / ga96 g64 / ga64 / g48 / ga48 gn48 gn32 / gna32 gn16 / gna16 g64 / g48 gn48 gn32 gn16 gn32 gn16 signal available on pin ? routing option on pin ? routing reset location not available on pin 100 64 48 32 20 i/o description
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 170 freescale semiconductor this section describes the signals available on each pin. although trying to enable multiple signals on a shared pin is not a proper use case in most applications, the resulting pin function will be determined by a prede?ed priority scheme as de?ed in 2.2.2 and 2.2.3. only enabled signals arbitrate for the pin and the highest priority de?es its data direction and output value if used as output. signals with programmable routing options are assumed to select the appropriate target pin to participate in the arbitration. the priority is represented for each pin with shared signals from highest to lowest in the following format: signala > signalb > gpo here signala has priority over signalb and general-purpose output function (gpo; represented by related port data register bit). the general-purpose output is always of lowest priority if no other signal is enabled. peripheral input signals on shared pins are always connected monitoring the pin level independent of their use.
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 171 2.3.1 pin bkgd 2.3.2 pins pa7-0 2.3.3 pins pb7-0 2.3.4 pins pc7-0 note when using ampm1, ampp1 or dacu1 please refer to section 2.6.1, ?nitialization ? table 2-5. pin bkgd bkgd the bkgd pin is associated with the bdm module in all packages. during reset, the bkgd pin is used as modc input. table 2-6. port a pins pa7-0 pa7-pa0 these pins feature general-purpose i/o functionality only. table 2-7. port b pins pb7-0 pb7-pb6 these pins feature general-purpose i/o functionality only. pb5 100 lqfp: the xirq signal is mapped to this pin when used with the xirq interrupt function. the interrupt is enabled by clearing the x mask bit in the cpu condition code register. the i/o state of the pin is forced to input level upon the ?st clearing of the x bit and held in this state even if the bit is set again. a stop or wait recovery with the x bit set (refer to cpu12/cpu12x reference manual) is not available. signal priority: 100 lqfp: xirq > gpo pb4 100 lqfp: the irq signal is mapped to this pin when used with the irq interrupt function. if enabled (irqen=1) the i/o state of the pin is forced to be an input. signal priority: 100 lqfp: irq > gpo pb3 this pin features general-purpose i/o functionality only. pb2 100 lqfp: the eclkx2 signal is mapped to this pin when used with the external clock function. the enabled eclkx2 signal forces the i/o state to an output. signal priority: 100 lqfp: eclkx2 > gpo pb1 100 lqfp: the api_extclk signal is mapped to this pin when used with the external clock function. if the autonomous periodic interrupt clock is enabled and routed here the i/o state is forced to output. signal priority: 100 lqfp: api_extclk > gpo pb0 100 lqfp: the eclk signal is mapped to this pin when used with the external clock function. the enabled eclk signal forces the i/o state to an output. signal priority: 100 lqfp: eclk > gpo
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 172 freescale semiconductor when routing of adc channels to pc4-pc0 is selected (prr1[prr1an]=1) the related bit in the adc digital input enable register (atddien) must be set to 1 to activate the digital input function on those pins not used as adc inputs. if the external trigger source is one of the adc channels, the digital input buffer of this channel is automatically enabled. table 2-8. port c pins pc7-0 pc7 100 lqfp: the unbuffered analog output signal dacu1 of the dac1 module is mapped to this pin if the dac is operating in ?nbuffered dac?mode. if this pin is used with the dac then the digital i/o function and pull device are disabled. signal priority: 100 lqfp: dacu1 > gpo pc6 100 lqfp: the non-inverting analog input signal ampp1 of the dac1 module is mapped to this pin if the dac is operating in ?nbuffered dac with operational ampli?r?or ?perational ampli?r only mode. if this pin is used with the dac then the digital input buffer is disabled. signal priority: 100 lqfp: gpo pc5 100 lqfp: the inverting analog input signal ampm1 of the dac1 module is mapped to this pin if the dac is operating in ?nbuffered dac with operational ampli?r?or ?perational ampli?r only?mode. if this pin is used with the dac then the digital input buffer is disabled. signal priority: 100 lqfp: gpo pc4-pc2 100 lqfp: if routing is active (prr1[prr1an]=1) the adc analog input channel signals an15-13 and their related digital trigger inputs are mapped to these pins. the routed adc function has no effect on the output state. refer to note/2-171 for input buffer control. signal priority: 100 lqfp: gpo pc1-pc0 100 lqfp: if routing is active (prr1[prr1an]=1) the adc analog input channel signals an11-10 and their related digital trigger inputs are mapped to these pins. the routed adc function has no effect on the output state. refer to note/2-171 for input buffer control. signal priority: 100 lqfp: gpo
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 173 2.3.5 pins pd7-0 2.3.6 pins pe1-0 2.3.7 pins pt7-0 table 2-9. port d pins pd7-0 pd7-pd0 these pins feature general-purpose i/o functionality only. table 2-10. port e pins pe1-0 pe1 if the cpmu osc function is active this pin is used as xtal signal and the pulldown device is disabled. 20 tssop: the sci0 txd signal is mapped to this pin when used with the sci function. if the sci0 txd signal is enabled and routed here the i/o state will depend on the sci0 con?uration. 20 tssop: the tim channel 3 signal is mapped to this pin when used with the timer function. the tim forces the i/o state to be an output for a timer port associated with an enabled output compare. 20 tssop: the pwm channel 1 signal is mapped to this pin when used with the pwm function. the enabled pwm channel forces the i/o state to be an output. 20 tssop: the adc etrig1 signal is mapped to this pin when used with the adc function. the enabled external trigger function has no effect on the i/o state. refer to section 2.6.4, ?dc external triggers etrig3-0 ? signal priority: 20 tssop: xtal > txd0 > ioc3 > pwm1 > gpo others: xtal > gpo pe0 if the cpmu osc function is active this pin is used as extal signal and the pulldown device is disabled. 20 tssop: the sci0 rxd signal is mapped to this pin when used with the sci function. if the sci0 rxd signal is enabled and routed here the i/o state will be forced to input. 20 tssop: the tim channel 2 signal is mapped to this pin when used with the timer function. the tim forces the i/o state to be an output for a timer port associated with an enabled output compare. 20 tssop: the pwm channel 0 signal is mapped to this pin when used with the pwm function. the enabled pwm channel forces the i/o state to be an output. 20 tssop: the adc etrig0 signal is mapped to this pin when used with the adc function. the enabled external trigger function has no effect on the i/o state. refer to section 2.6.4, ?dc external triggers etrig3-0 ? signal priority: 20 tssop: extal > rxd0 > ioc2 > pwm0 > gpo others: extal > gpo table 2-11. port t pins pt7-0 pt7-pt6 64/100 lqfp: the tim channels 7 and 6 signal are mapped to these pins when used with the timer function. the tim forces the i/o state to be an output for a timer port associated with an enabled output compare. signal priority: 64/100 lqfp: ioc7-6 > gpo pt5 48/64/100 lqfp: the tim channel 5 signal is mapped to this pin when used with the timer function. the tim forces the i/o state to be an output for a timer port associated with an enabled output compare. if the acmp timer link is enabled this pin is disconnected from the timer input so that it can still be used as general-purpose i/o or as timer output. the use case for the acmp timer link requires the timer input capture function to be enabled. signal priority: 48/64/100 lqfp: ioc5 > gpo
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 174 freescale semiconductor pt4 48/64/100 lqfp: the tim channel 4 signal is mapped to this pin when used with the timer function. the tim forces the i/o state to be an output for a timer port associated with an enabled output compare. signal priority: 48/64/100 lqfp: ioc4 > gpo pt3-pt2 except 20 tssop: the tim channels 3 and 2 signal are mapped to these pins when used with the timer function. the tim forces the i/o state to be an output for a timer port associated with an enabled output compare. signal priority: except 20 tssop: ioc3-2 > gpo pt1 except 100 lqfp: the irq signal is mapped to this pin when used with the irq interrupt function. if enabled (irqcr[irqen]=1) the i/o state of the pin is forced to be an input. the tim channel 1 signal is mapped to this pin when used with the timer function. the tim forces the i/o state to be an output for a timer port associated with an enabled output compare. signal priority: 100 lqfp: ioc1 > gpo others: irq > ioc1 > gpo pt0 except 100 lqfp: the xirq signal is mapped to this pin when used with the xirq interrupt function.the interrupt is enabled by clearing the x mask bit in the cpu condition code register. the i/o state of the pin is forced to input level upon the ?st clearing of the x bit and held in this state even if the bit is set again. a stop or wait recovery with the x bit set (refer to cpu12/cpu12x reference manual) is not available. the tim channel 0 signal is mapped to this pin when used with the timer function. the tim forces the i/o state to be an output for a timer port associated with an enabled output compare. signal priority: 100 lqfp: ioc0 > gpo others: xirq > ioc0 > gpo table 2-11. port t pins pt7-0 (continued)
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 175 2.3.8 pins ps7-0 table 2-12. port s pins ps7-0 ps7 the spi0 ss signal is mapped to this pin when used with the spi function. depending on the con?uration of the enabled spi0 the i/o state is forced to be input or output. 20 tssop: the sci0 txd signal is mapped to this pin when used with the sci function. if the sci0 txd signal is enabled and routed here the i/o state will depend on the sci0 con?uration. 20 tssop: the pwm channel 3 signal is mapped to this pin when used with the pwm function. if the pwm channel is enabled and routed here the i/o state is forced to output.the enabled pwm channel forces the i/o state to be an output. 32 lqfp: the pwm channel 5 signal is mapped to this pin when used with the pwm function. the enabled pwm channel forces the i/o state to be an output. 64/48/32/20 lqfp: the eclk signal is mapped to this pin when used with the external clock function. if the eclk output is enabled the i/o state will be forced to output. the api_extclk signal is mapped to this pin when used with the external clock function. if the autonomous periodic interrupt clock is enabled and routed here the i/o state is forced to output. 20 tssop: the adc etrig3 signal is mapped to this pin if pwm channel 3 is routed here. the enabled external trigger function has no effect on the i/o state. refer to section 2.6.4, ?dc external triggers etrig3-0 ? signal priority: 20 tssop: ss0 > txd0 > pwm3 > eclk > api_extclk > gpo 32 lqfp: ss0 > pwm5 > eclk > api_extclk > gpo 48/64 lqfp: ss0 > eclk > api_extclk > gpo 100 lqfp: ss0 > api_extclk > gpo ps6 the spi0 sck signal is mapped to this pin when used with the spi function. depending on the con?uration of the enabled spi0 the i/o state is forced to be input or output. 20 tssop: the tim channel 3 signal is mapped to this pin when used with the timer function. if the tim output compare signal is enabled and routed here the i/o state will be forced to output. 32 lqfp: the tim channel 5 signal is mapped to this pin when used with the timer function. if the tim output compare signal is enabled and routed here the i/o state will be forced to output. if the acmp timer link is enabled this pin is disconnected from the timer input so that it can still be used as general-purpose i/o or as timer output. the use case for the acmp timer link requires the timer input capture function to be enabled. signal priority: 20 tssop: sck0 > ioc3 > gpo 32 lqfp: sck0 > ioc5 > gpo others: sck0 > gpo ps5 the spi0 mosi signal is mapped to this pin when used with the spi function. depending on the con?uration of the enabled spi0 the i/o state is forced to be input or output. 20 tssop: the tim channel 2 signal is mapped to this pin when used with the timer function. if the tim output compare signal is enabled and routed here the i/o state will be forced to output. 32 lqfp: the tim channel 4 signal is mapped to this pin when used with the timer function. if the tim output compare signal is enabled and routed here the i/o state will be forced to output. signal priority: 20 tssop: mosi0 > ioc2 > gpo 32 lqfp: mosi0 > ioc4 > gpo others: mosi0 > gpo
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 176 freescale semiconductor ps4 the spi0 miso signal is mapped to this pin when used with the spi function. depending on the con?uration of the enabled spi0 the i/o state is forced to be input or output. 20 tssop: the sci0 rxd signal is mapped to this pin when used with the sci function. if the sci0 rxd signal is enabled and routed here the i/o state will be forced to input. 20 tssop: the pwm channel 2 signal is mapped to this pin when used with the pwm function. if the pwm channel is enabled and routed here the i/o state is forced to output. 32 lqfp: the pwm channel 4 signal is mapped to this pin when used with the pwm function. the enabled pwm channel forces the i/o state to be an output. 20 tssop: the adc etrig2 signal is mapped to this pin if pwm channel 2 is routed here. the enabled external trigger function has no effect on the i/o state. refer to section 2.6.4, ?dc external triggers etrig3-0 ? signal priority: 20 tssop: miso0 > rxd0 > pwm2 > gpo 32 lqfp: miso0 > pwm4 > gpo others: miso0 > gpo ps3 except 20 tssop and 32 lqfp: the sci1 txd signal is mapped to this pin when used with the sci function. if the sci1 txd signal is enabled the i/o state will depend on the sci1 con?uration. signal priority: 48/64/100 lqfp: txd1 > gpo ps2 except 20 tssop and 32 lqfp: the sci1 rxd signal is mapped to this pin when used with the sci function. if the sci1 rxd signal is enabled the i/o state will be forced to be input. signal priority: 20 tssop and 32 lqfp: gpo others: rxd1 > gpo ps1 except 20 tssop: the sci0 txd signal is mapped to this pin when used with the sci function. if the sci0 txd signal is enabled the i/o state will depend on the sci0 con?uration. signal priority: except 20 tssop: txd0 > gpo ps0 except 20 tssop: the sci0 rxd signal is mapped to this pin when used with the sci function. if the sci0 rxd signal is enabled the i/o state will be forced to be input. signal priority: 20 tssop: gpo others: rxd0 > gpo table 2-12. port s pins ps7-0 (continued)
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 177 2.3.9 pins pm3-0 2.3.10 pins pp7-0 table 2-13. port m pins pm3-0 pm3 64/100 lqfp: the sci2 txd signal is mapped to this pin when used with the sci function. if the sci2 txd signal is enabled the i/o state will depend on the sci2 con?uration. signal priority: 64/100 lqfp: txd2 > gpo pm2 64/100 lqfp: the sci2 rxd signal is mapped to this pin when used with the sci function. if the sci2 rxd signal is enabled the i/o state will be forced to be input. signal priority: 64/100 lqfp: rxd2 > gpo pm1 except 20 tssop: the txcan signal is mapped to this pin when used with the can function. the enabled can forces the i/o state to be an output. 32 lqfp: the sci1 txd signal is mapped to this pin when used with the sci function. if the sci1 txd signal is enabled the i/o state will depend on the sci1 con?uration. 48 lqfp: the sci2 txd signal is mapped to this pin when used with the sci function. if the sci2 txd signal is enabled the i/o state will depend on the sci2 con?uration. signal priority: 32 lqfp: txcan > txd1 > gpo 48 lqfp: txcan > txd2 > gpo 64/100 lqfp: txcan > gpo pm0 except 20 tssop: the rxcan signal is mapped to this pin when used with the can function. the enabled can forces the i/o state to be an input. if can is active the selection of a pulldown device on the rxcan input has no effect. 32 lqfp: the sci1 rxd signal is mapped to this pin when used with the sci function. the enabled sci1 rxd signal forces the i/o state to an input. 48 lqfp: the sci2 rxd signal is mapped to this pin when used with the sci function. the enabled sci2 rxd signal forces the i/o state to an input. signal priority: 32 lqfp: rxcan > rxd1 > gpo 48 lqfp: rxcan > rxd2 > gpo 64/100 lqfp: rxcan > gpo table 2-14. port p pins pp7-0 pp7-pp6 64/100 lqfp: the pwm channels 7 and 6 signal are mapped to these pins when used with the pwm function. the enabled pwm channel forces the i/o state to be an output. 64/100 lqfp: pin interrupts can be generated if enabled in input or output mode. signal priority: 64/100 lqfp: pwm > gpo pp5-pp4 48/64/100 lqfp: the pwm channels 5 and 4 signal are mapped to these pins when used with the pwm function. the enabled pwm channel forces the i/o state to be an output. 48/64/100 lqfp: pin interrupts can be generated if enabled in input or output mode. signal priority: 48/64/100 lqfp: pwm > gpo
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 178 freescale semiconductor pp3-pp2 except 20 tssop: the pwm channels 3 and 2 signal are mapped to these pins when used with the pwm function. the enabled pwm channel forces the i/o state to be an output. except 20 tssop: the adc etrig 3 and 2 signal are mapped to these pins when used with the adc function. the enabled external trigger function has no effect on the i/o state. refer to section 2.6.4, ?dc external triggers etrig3-0 ? except 20 tssop: pin interrupts can be generated if enabled in input or output mode. signal priority: except 20 tssop: pwm > gpo pp1 except 20 tssop: the pwm channel 1 signal is mapped to this pin when used with the pwm function. the enabled pwm channel forces the i/o state to be an output. except 100 lqfp and 20 tssop: the eclkx2 signal is mapped to this pin when used with the external clock function. the enabled eclkx2 forces the i/o state to an output. except 20 tssop: the adc etrig1 signal is mapped to this pin when used with the adc function. the enabled external trigger function has no effect on the i/o state. refer to section 2.6.4, ?dc external triggers etrig3-0 ? except 20 tssop: pin interrupts can be generated if enabled in input or output mode. signal priority: except 100 lqfp and 20 tssop: pwm1 > eclkx2 > gpo 100 lqfp: pwm1 > gpo pp0 except 20 tssop: the pwm channel 0 signal is mapped to this pin when used with the pwm function. the enabled pwm channel forces the i/o state to be an output. except 100 lqfp and 20 tssop: the api_extclk signal is mapped to this pin when used with the external clock function. if the autonomous periodic interrupt clock is enabled and routed here the i/o state is forced to output. except 20 tssop: the adc etrig0 signal is mapped to this pin when used with the adc function. the enabled external trigger function has no effect on the i/o state. refer to section 2.6.4, ?dc external triggers etrig3-0 ? except 20 tssop: pin interrupts can be generated if enabled in input or output mode. signal priority: except 100 lqfp and 20 tssop: pwm0 > api_extclk > gpo 100 lqfp: pwm0 > gpo table 2-14. port p pins pp7-0 (continued)
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 179 2.3.11 pins pj7-0 table 2-15. port j pins pj7-0 pj7 64/100 lqfp: the spi2 ss signal is mapped to this pin when used with the spi function. depending on the con?uration of the enabled spi2 the i/o state is forced to be input or output. 64/100 lqfp: pin interrupts can be generated if enabled in input or output mode. signal priority: 64/100 lqfp: ss2 > gpo pj6 64/100 lqfp: the spi2 sck signal is mapped to this pin when used with the spi function. depending on the con?uration of the enabled spi2 the i/o state is forced to be input or output. 64/100 lqfp: pin interrupts can be generated if enabled in input or output mode. signal priority: 64/100 lqfp: sck2 > gpo pj5 64/100 lqfp: the spi2 mosi signal is mapped to this pin when used with the spi function. depending on the con?uration of the enabled spi2 the i/o state is forced to be input or output. 64/100 lqfp: pin interrupts can be generated if enabled in input or output mode. signal priority: 64/100 lqfp: mosi2 > gpo pj4 64/100 lqfp: the spi2 miso signal is mapped to this pin when used with the spi function.depending on the con?uration of the enabled spi2 the i/o state is forced to be input or output. 64/100 lqfp: pin interrupts can be generated if enabled in input or output mode. signal priority: 64/100 lqfp: miso2 > gpo pj3 except 20 tssop and 32 lqfp: the spi1 ss signal is mapped to this pin when used with the spi function. depending on the con?uration of the enabled spi1 the i/o state is forced to be input or output. 48 lqfp: the pwm channel 7 signal is mapped to this pin when used with the pwm function. the enabled pwm channel forces the i/o state to be an output. except 20 tssop and 32 lqfp: pin interrupts can be generated if enabled in input or output mode. signal priority: 48 lqfp: ss1 > pwm7 > gpo 64/100 lqfp: ss1 > gpo pj2 except 20 tssop and 32 lqfp: the spi1 sck signal is mapped to this pin when used with the spi function. depending on the con?uration of the enabled spi1 the i/o state is forced to be input or output. 48 lqfp: the tim channel 7 signal is mapped to this pin when used with the tim function. the tim forces the i/o state to be an output for a timer port associated with an enabled output. except 20 tssop and 32 lqfp: pin interrupts can be generated if enabled in input or output mode. signal priority: 48 lqfp: sck1 > ioc7 > gpo 64/100 lqfp: sck1 > gpo
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 180 freescale semiconductor 2.3.12 pins ad15-0 note the following sources contribute to enable the input buffers on port ad: digital input enable register bits set for each individual pin in adc external trigger function of adc enabled on adc channel adc channels routed to port c freeing up pins digital input enable register set bit in and acmp taking the availability of the different sources on each pin into account the following logic equation must be true to activate the digital input buffer for general-purpose input use: ibex = ( (atddienh/l[ienx]=1) or (atdctl1[etrigsel]=0 and atdctl2[etrige]=1) or (prr1[prr1an]=1) ) and (acdien=1) eqn. 2-1 pj1 except 20 tssop and 32 lqfp: the spi1 mosi signal is mapped to this pin when used with the spi function. depending on the con?uration of the enabled spi1 the i/o state is forced to be input or output. 48 lqfp: the tim channel 6 signal is mapped to this pin when used with the timer function. the tim forces the i/o state to be an output for a timer port associated with an enabled output. except 20 tssop and 32 lqfp: pin interrupts can be generated if enabled in input or output mode. signal priority: 48 lqfp: mosi1 > ioc6 > gpo 64/100 lqfp: mosi1 > gpo pj0 except 20 tssop and 32 lqfp: the spi1 miso signal is mapped to this pin when used with the spi function. depending on the con?uration of the enabled spi1 the i/o state is forced to be input or output. 48 lqfp: the pwm channel 6 signal is mapped to this pin when used with the pwm function. the enabled pwm channel forces the i/o state to be an output. except 20 tssop and 32 lqfp: pin interrupts can be generated if enabled in input or output mode. signal priority: 48 lqfp: miso1 > pwm6 > gpo 64/100 lqfp: miso1 > gpo table 2-15. port j pins pj7-0 (continued)
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 181 table 2-16. port ad pins ad15-8 pad15 64/100 lqfp: the unbuffered analog output signal dacu0 of the dac0 module is mapped to this pin if the dac is operating in ?nbuffered dac?mode. if this pin is used with the dac then the digital i/o function and pull device are disabled. 64/100 lqfp: if routing is inactive (prr1[prr1an]=0) the adc analog input channel signal an15 and the related digital trigger input are mapped to this pin. the adc function has no effect on the output state. refer to note/2-180 for input buffer control. 64/100 lqfp: pin interrupts can be generated if enabled in digital input or output mode. signal priority: 64/100 lqfp: dacu0 > gpo pad14 64/100 lqfp: the non-inverting analog input signal ampp0 of the dac0 module is mapped to this pin if the dac is operating in ?nbuffered dac with operational ampli?r?or ?perational ampli?r only mode. if this pin is used with the dac then the digital input buffer is disabled. 64/100 lqfp: if routing is inactive (prr1[prr1an]=0) the adc analog input channel signal an14 and the related digital trigger input are mapped to this pin. the adc function has no effect on the output state. refer to note/2-180 for input buffer control. 64/100 lqfp: pin interrupts can be generated if enabled in digital input or output mode. signal priority: 64/100 lqfp: gpo pad13 64/100 lqfp: the inverting analog input signal ampm0 of the dac0 module is mapped to this pin if the dac is operating in ?nbuffered dac with operational ampli?r?or ?perational ampli?r only mode. if this pin is used with the dac then the digital input buffer is disabled. 64/100 lqfp: if routing is inactive (prr1[prr1an]=0) the adc analog input channel signal an13 and the related digital trigger input are mapped to this pin. the adc function has no effect on the output state. refer to note/2-180 for input buffer control. 64/100 lqfp: pin interrupts can be generated if enabled in digital input or output mode. signal priority: 64/100 lqfp: gpo pad12 64/100 lqfp: the adc analog input channel signal an12 and the related digital trigger input are mapped to this pin. the adc function has no effect on the output state. refer to note/2-180 for input buffer control. 64/100 lqfp: pin interrupts can be generated if enabled in digital input or output mode. signal priority: 64/100 lqfp: gpo
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 182 freescale semiconductor pad11 64/100 lqfp: the buffered analog output signal amp0 of the dac0 module is mapped to this pin if the dac is operating in ?uffered dac? ?nbuffered dac with operational ampli?r?or ?perational ampli?r only?mode. if this pin is used with the dac then the digital i/o function and pull device are disabled. 48 lqfp: the buffered analog output signal amp0 of the dac0 module is mapped to this pin if the dac is operating in ?uffered dac? ?nbuffered dac with operational ampli?r 1 or ?perational ampli?r only?mode. if this pin is used with the dac then the digital i/o function and pull device are disabled. 48 lqfp: the unbuffered analog output signal dacu0 of the dac0 module is mapped to this pin if the dac is operating in ?nbuffered dac?mode. if this pin is used with the dac then the digital output function and pull device are disabled. 48/64 lqfp: the inverting input signal acmpm of the analog comparator is mapped to this pin when used with the acmp function. the acmp function has no effect on the output state. refer to note/2-180 for input buffer control. 48/64/100 lqfp: if routing is inactive (prr1[prr1an]=0) the adc analog input channel signal an11 and the related digital trigger input are mapped to this pin. the adc function has no effect on the output state. refer to note/2-180 for input buffer control. 48/64/100 lqfp: pin interrupts can be generated if enabled in digital input or output mode. signal priority: 48 lqfp: amp0 > dacu0 > gpo 64/100 lqfp: amp0 > gpo pad10 100 lqfp: the buffered analog output signal amp1 of the dac1 module is mapped to this pin if the dac is operating in ?uffered dac? ?nbuffered dac with operational ampli?r?or ?perational ampli?r only?mode. if this pin is used with the dac then the digital i/o function and pull device are disabled. 48/64 lqfp: the buffered analog output signal amp1 of the dac1 module is mapped to this pin if the dac is operating in ?uffered dac? ?nbuffered dac with operational ampli?r 1 or ?perational ampli?r only mode. if this pin is used with the dac then the digital output function and pull device are disabled. 48/64 lqfp: the unbuffered analog output signal dacu1 of the dac1 module is mapped to this pin if the dac is operating in ?nbuffered dac mode. if this pin is used with the dac then the digital output function and pull device are disabled. 48/64 lqfp: the non-inverting input signal acmpp of the analog comparator is mapped to this pin when used with the acmp function. the acmp function has no effect on the output state. refer to note/2-180 for input buffer control. 48/64/100 lqfp: if routing is inactive (prr1[prr1an]=0) the adc analog input channel signal an10 and the related digital trigger input are mapped to this pin. the adc function has no effect on the output state. refer to note/2-180 for input buffer control. 48/64/100 lqfp: pin interrupts can be generated if enabled in digital input or output mode. signal priority: 48/64 lqfp: amp1 > dacu1 > gpo 100 lqfp: amp1 > gpo table 2-16. port ad pins ad15-8
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 183 pad9 48/64 lqfp: the acmpo signal of the analog comparator is mapped to this pin when used with the acmp function. if the acmp output is enabled (acmpc[acope]=1) the i/o state will be forced to output. 48/64/100 lqfp: the adc analog input channel signal an9 and the related digital trigger input are mapped to this pin. the adc function has no effect on the output state. refer to note/2-180 for input buffer control. 48/64/100 lqfp: pin interrupts can be generated if enabled in digital input or output mode. signal priority: 48 lqfp: acmpo > gpo 64/100 lqfp: gpo pad8 48/64/100 lqfp: the adc analog input channel signal an8 and the related digital trigger input are mapped to this pin. the adc function has no effect on the output state. refer to note/2-180 for input buffer control. 48/64/100 lqfp: pin interrupts can be generated if enabled in digital input or output mode. signal priority: 48/64/100 lqfp: gpo 1 amp output takes precedence over dacu output on shared pin. table 2-17. port ad pins ad7-0 pad7 32 lqfp: the inverting input signal acmpm of the analog comparator is mapped to this pin when used with the acmp function. the acmp function has no effect on the output state. refer to note/2-180 for input buffer control. except 20 tssop: the adc analog input channel signal an7 and the related digital trigger input are mapped to this pin. the adc function has no effect on the output state. refer to note/2-180 for input buffer control. except 20 tssop: pin interrupts can be generated if enabled in digital input or output mode. signal priority: except 20 tssop: gpo pad6 32 lqfp: the non-inverting input signal acmpp of the analog comparator is mapped to this pin when used with the acmp function. the acmp function has no effect on the output state. refer to note/2-180 for input buffer control. except 20 tssop: the adc analog input channel signal an6 and the related digital trigger input are mapped to this pin. the adc function has no effect on the output state. refer to note/2-180 for input buffer control. except 20 tssop: pin interrupts can be generated if enabled in digital input or output mode. signal priority: except 20 tssop: gpo table 2-16. port ad pins ad15-8
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 184 freescale semiconductor pad5 32 lqfp: the acmpo signal of the analog comparator is mapped to this pin when used with the acmp function. if the acmp output is enabled (acmpc[acope]=1) the i/o state will be forced to output. 20 tssop: the inverting input signal acmpm of the analog comparator is mapped to this pin when used with the acmp function. the acmp function has no effect on the output state. refer to note/2-180 for input buffer control. the adc analog input channel signal an5 and the related digital trigger input are mapped to this pin. the adc function has no effect on the output state. refer to note/2-180 for input buffer control. 20 tssop: the sci0 txd signal is mapped to this pin. if the sci0 txd signal is enabled the i/o state will depend on the sci0 con?uration. 20 tssop: the tim channel 3 signal is mapped to this pin. the tim forces the i/o state to be an output for a timer port associated with an enabled output compare. 20 tssop: the pwm channel 3 signal is mapped to this pin. if the pwm channel is enabled and routed here the i/o state is forced to output. 20 tssop: the adc etrig3 signal is mapped to this pin if pwm channel 3 is routed here. the enabled external trigger function has no effect on the i/o state. refer to section 2.6.4, ?dc external triggers etrig3-0 ? pin interrupts can be generated if enabled in digital input or output mode. signal priority: 32 lqfp: acmpo > gpo 20 tssop: txd0 > ioc3 > pwm3 > gpo others: gpo pad4 20 tssop: the non-inverting input signal acmpp of the analog comparator is mapped to this pin when used with the acmp function. the acmp function has no effect on the output state. refer to note/2-180 for input buffer control. the adc analog input channel signal an4 and the related digital trigger input are mapped to this pin. the adc function has no effect on the output state. refer to note/2-180 for input buffer control. 20 tssop: the sci0 rxd signal is mapped to this pin. if the sci0 rxd signal is enabled and routed here the i/o state will be forced to input. 20 tssop: the tim channel 2 signal is mapped to this pin. the tim forces the i/o state to be an output for a timer port associated with an enabled output compare. 20 tssop: the pwm channel 2 signal is mapped to this pin. if the pwm channel is enabled and routed here the i/o state is forced to output. 20 tssop: the adc etrig2 signal is mapped to this pin if pwm channel 2 is routed here. the enabled external trigger function has no effect on the i/o state. refer to section 2.6.4, ?dc external triggers etrig3-0 ? pin interrupts can be generated if enabled in digital input or output mode. signal priority: 20 tssop: rxd0 > ioc2 > pwm2 > gpo others: gpo table 2-17. port ad pins ad7-0 (continued)
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 185 pad3 20 tssop: the acmpo signal of the analog comparator is mapped to this pin when used with the acmp function. if the acmp output is enabled (acmpc[acope]=1) the i/o state will be forced to output. the adc analog input channel signal an3 and the related digital trigger input are mapped to this pin. the adc function has no effect on the output state. refer to note/2-180 for input buffer control. pin interrupts can be generated if enabled in digital input or output mode. signal priority: 20 tssop: acmpo > gpo others: gpo pad2-pad0 the adc analog input channel signals an2-0 and their related digital trigger inputs are mapped to this pin. the adc function has no effect on the output state. refer to note/2-180 for input buffer control. pin interrupts can be generated if enabled in digital input or output mode. signal priority: gpo table 2-17. port ad pins ad7-0 (continued)
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 186 freescale semiconductor 2.4 pim ports - memory map and register de?ition this section provides a detailed description of all pim registers. 2.4.1 memory map table 2-18 shows the memory maps of all groups (for de?itions see table 2-2 ). addresses 0x0000 to 0x0007 are only implemented in group g1 otherwise reserved. table 2-18. block memory map (0x0000-0x027f) port global address register access reset value section/page (a) (b) 0x0000 porta?ort a data register 1 r/w 0x00 2.4.3.1/2-205 0x0001 portb?ort b data register 1 r/w 0x00 2.4.3.2/2-205 0x0002 ddra?ort a data direction register 1 r/w 0x00 2.4.3.3/2-206 0x0003 ddrb?ort b data direction register 1 r/w 0x00 2.4.3.4/2-207 (c) (d) 0x0004 portc?ort c data register 1 r/w 0x00 2.4.3.5/2-207 0x0005 portd?ort d data register 1 r/w 0x00 2.4.3.6/2-208 0x0006 ddrc?ort c data direction register 1 r/w 0x00 2.4.3.7/2-209 0x0007 ddrd?ort d data direction register 1 r/w 0x00 2.4.3.8/2-209 e 0x0008 porte?ort e data register r/w 0x00 0x0009 ddre?ort e data direction register r/w 0x00 0x000a : 0x000b non-pim address range 2 - - - (a) (b) (c) (d) e 0x000c pucr?ull control register r/w 0x50 2.4.3.11/2-211 0x000d reserved r 0x00 0x000e : 0x001b non-pim address range 2 - - - 0x001c eclkctl?clk control register r/w 0xc0 2.4.3.12/2-213 0x001d reserved r 0x00 0x001e irqcr?rq control register r/w 0x00 2.4.3.13/2-213 0x001f reserved r 0x00 0x0020 : 0x023f non-pim address range 2 - - -
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 187 t 0x0240 ptt?ort t data register r/w 0x00 2.4.3.15/2-215 0x0241 ptit?ort t input register r 3 2.4.3.16/2-215 0x0242 ddrt?ort t data direction register r/w 0x00 2.4.3.17/2-216 0x0243 reserved r 0x00 0x0244 pert?ort t pull device enable register r/w 0x00 2.4.3.18/2-217 0x0245 ppst?ort t polarity select register r/w 0x00 2.4.3.19/2-218 0x0246 reserved r 0x00 0x0247 reserved r 0x00 s 0x0248 pts?ort s data register r/w 0x00 2.4.3.20/2-218 0x0249 ptis?ort s input register r 3 2.4.3.21/2-219 0x024a ddrs?ort s data direction register r/w 0x00 2.4.3.22/2-219 0x024b reserved r 0x00 0x024c pers?ort s pull device enable register r/w 0xff 2.4.3.23/2-220 0x024d ppss?ort s polarity select register r/w 0x00 2.4.3.24/2-220 0x024e woms?ort s wired-or mode register r/w 0x00 2.4.3.25/2-221 0x024f prr0?in routing register 0 4 r/w 0x00 2.4.3.26/2-221 m 0x0250 ptm?ort m data register r/w 0x00 2.4.3.27/2-223 0x0251 ptim?ort m input register r 3 2.4.3.29/2-224 0x0252 ddrm?ort m data direction register r/w 0x00 2.4.3.29/2-224 0x0253 reserved r 0x00 0x0254 perm?ort m pull device enable register r/w 0x00 2.4.3.30/2-225 0x0255 ppsm?ort m polarity select register r/w 0x00 2.4.3.31/2-226 0x0256 womm?ort m wired-or mode register r/w 0x00 2.4.3.32/2-226 0x0257 pkgcr?ackage code register r/w 5 2.4.3.33/2-227 p 0x0258 ptp?ort p data register r/w 0x00 2.4.3.34/2-228 0x0259 ptip?ort p input register r 3 2.4.3.35/2-229 0x025a ddrp?ort p data direction register r/w 0x00 2.4.3.36/2-230 0x025b reserved r 0x00 0x025c perp?ort p pull device enable register r/w 0x00 2.4.3.37/2-230 0x025d ppsp?ort p polarity select register r/w 0x00 2.4.3.38/2-231 0x025e piep?ort p interrupt enable register r/w 0x00 2.4.3.39/2-232 0x025f pifp?ort p interrupt flag register r/w 0x00 2.4.3.40/2-232 table 2-18. block memory map (0x0000-0x027f) (continued) port global address register access reset value section/page
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 188 freescale semiconductor 0x0260 reserved for acmp available in group g2 and g3 r(/w) 0x00 (acmp) 0x0261 r(/w) 0x00 (acmp) 0x0262 : 0x0266 reserved r 0x00 j 0x0268 ptj?ort j data register r/w 0x00 2.4.3.42/2-234 0x0269 ptij?ort j input register r 3 2.4.3.43/2-235 0x026a ddrj?ort j data direction register r/w 0x00 2.4.3.44/2-235 0x026b reserved r 0x00 0x026c perj?ort j pull device enable register r/w 0xff ( g1 , g2 ) 0x0f ( g3 ) 2.4.3.45/2-236 0x026d ppsj?ort j polarity select register r/w 0x00 2.4.3.46/2-237 0x026e piej?ort j interrupt enable register r/w 0x00 2.4.3.47/2-237 0x026f pifj?ort j interrupt flag register r/w 0x00 2.4.3.48/2-238 ad 0x0270 pt0ad?ort ad data register r/w 0x00 2.4.3.49/2-239 0x0271 pt1ad?ort ad data register r/w 0x00 2.4.3.50/2-239 0x0272 pti0ad?ort ad input register r 3 2.4.3.51/2-240 0x0273 pti1ad?ort ad input register r 3 2.4.3.54/2-241 0x0274 ddr0ad?ort ad data direction register r/w 0x00 2.4.3.53/2-241 0x0275 ddr1ad?ort ad data direction register r/w 0x00 2.4.3.54/2-241 0x0276 reserved for rvactl on g(a)240 and g(a)192 only r(/w) 0x00 (rva) 0x0277 prr1?in routing register 1 6 r/w 0x00 2.4.3.56/2-242 0x0278 per0ad?ort ad pull device enable register r/w 0x00 2.4.3.57/2-243 0x0279 per1ad?ort ad pull device enable register r/w 0x00 2.4.3.58/2-244 0x027a pps0ad?ort ad polarity select register r/w 0x00 2.4.3.59/2-244 0x027b pps1ad?ort ad polarity select register r/w 0x00 2.4.3.60/2-245 0x027c pie0ad?ort ad interrupt enable register r/w 0x00 2.4.3.61/2-246 0x027d pie1ad?ort ad interrupt enable register r/w 0x00 2.4.3.62/2-246 0x027e pif0ad?ort ad interrupt flag register r/w 0x00 2.4.3.63/2-247 0x027f pif1ad?ort ad interrupt flag register r/w 0x00 2.4.3.64/2-248 1 available in group g1 only. in any other case this address is reserved. 2 refer to device memory map to determine related module. 3 read always returns logic level on pins. 4 routing takes only effect if the pkgcr is set to 20 tssop. table 2-18. block memory map (0x0000-0x027f) (continued) port global address register access reset value section/page
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 189 2.4.2 register map the following tables show the individual register maps of groups g1 ( table 2-19 ), g2 ( table 2-20 ) and g3 ( table 2-21 ). note to maintain sw compatibility write data to unimplemented register bits must be zero. 2.4.2.1 block register map ( g1 ) 5 preset by factory. 6 routing register only available on g(a)240 and g(a)192 only. takes only effect if the pkgcr is set to 100 lqfp. table 2-19. block register map ( g1 ) global address register name bit 7 654321 bit 0 0x0000 porta r pa 7 pa 6 pa 5 pa 4 pa 3 pa 2 pa 1 pa 0 w 0x0001 portb r pb7 pb6 pb5 pb4 pb3 pb2 pb1 pb0 w 0x0002 ddra r ddra7 ddra6 ddra5 ddra4 ddra3 ddra2 ddra1 ddra0 w 0x0003 ddrb r ddrb7 ddrb6 ddrb5 ddrb4 ddrb3 ddrb2 ddrb1 ddrb0 w 0x0004 portc r pc7 pc6 pc5 pc4 pc3 pc2 pc1 pc0 w 0x0005 portd r pd7 pd6 pd5 pd4 pd3 pd2 pd1 pd0 w 0x0006 ddrc r ddrc7 ddrc6 ddrc5 ddrc4 ddrc3 ddrc2 ddrc1 ddrc0 w 0x0007 ddrd r ddrd7 ddrd6 ddrd5 ddrd4 ddrd3 ddrd2 ddrd1 ddrd0 0x0008 porte r000000 pe1 pe0 w 0x0009 ddre r000000 ddre1 ddre0 w = unimplemented or reserved
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 190 freescale semiconductor 0x000a?x000b non-pim address range r non-pim address range w 0x000c pucr r0 bkpue 0 pdpee pupde pupce pupbe pupae w 0x000d reserved r00000000 w 0x000e?x001b non-pim address range r non-pim address range w 0x001c eclkctl r neclk nclkx2 div16 ediv4 ediv3 ediv2 ediv1 ediv0 w 0x001d reserved r00000000 w 0x001e irqcr r irqe irqen 000000 w 0x001f reserved r reserved reserved reserved reserved reserved reserved reserved reserved w 0x0020?x023f non-pim address range r non-pim address range w 0x0240 ptt r ptt7 ptt6 ptt5 ptt4 ptt3 ptt2 ptt1 ptt0 w 0x0241 ptit r ptit7 ptit6 ptit5 ptit4 ptit3 ptit2 ptit1 ptit0 w 0x0242 ddrt r ddrt7 ddrt6 ddrt5 ddrt4 ddrt3 ddrt2 ddrt1 ddrt0 w 0x0243 reserved r00000000 w 0x0244 pert r pert7 pert6 pert5 pert4 pert3 pert2 pert1 pert0 w 0x0245 ppst r ppst7 ppst6 ppst5 ppst4 ppst3 ppst2 ppst1 ppst0 w table 2-19. block register map ( g1 ) (continued) global address register name bit 7 654321 bit 0 = unimplemented or reserved
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 191 0x0246 reserved r00000000 w 0x0247 reserved r00000000 w 0x0248 pts r pts7 pts6 pts5 pts4 pts3 pts2 pts1 pts0 w 0x0249 ptis r ptis7 ptis6 ptis5 ptis4 ptis3 ptis2 ptis1 ptis0 w 0x024a ddrs r ddrs7 ddrs6 ddrs5 ddrs4 ddrs3 ddrs2 ddrs1 ddrs0 w 0x024b reserved r00000000 w 0x024c pers r pers7 pers6 pers5 pers4 pers3 pers2 pers1 pers0 w 0x024d ppss r ppss7 ppss6 ppss5 ppss4 ppss3 ppss2 ppss1 ppss0 w 0x024e woms r woms7 woms6 woms5 woms4 woms3 woms2 woms1 woms0 w 0x024f prr0 r prr0p3 prr0p2 prr0t31 prr0t30 prr0t21 prr0t20 prr0s1 prr0s0 w 0x0250 ptm r0000 ptm3 ptm2 ptm1 ptm0 w 0x0251 ptim r0000 ptim3 ptim2 ptim1 ptim0 w 0x0252 ddrm r0000 ddrm3 ddrm2 ddrm1 ddrm0 w 0x0253 reserved r00000000 w 0x0254 perm r0000 perm3 perm2 perm1 perm0 w table 2-19. block register map ( g1 ) (continued) global address register name bit 7 654321 bit 0 = unimplemented or reserved
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 192 freescale semiconductor 0x0255 ppsm r0000 ppsm3 ppsm2 ppsm1 ppsm0 w 0x0256 womm r0000 womm3 womm2 womm1 womm0 w 0x0257 pkgcr r apiclks7 0000 pkgcr2 pkgcr1 pkgcr0 w 0x0258 ptp r ptp7 ptp6 ptp5 ptp4 ptp3 ptp2 ptp1 ptp0 w 0x0259 ptip r ptip7 ptip6 ptip5 ptip4 ptip3 ptip2 ptip1 ptip0 w 0x025a ddrp r ddrp7 ddrp6 ddrp5 ddrp4 ddrp3 ddrp2 ddrp1 ddrp0 w 0x025b reserved r00000000 w 0x025c perp r perp7 perp6 perp5 perp4 perp3 perp2 perp1 perp0 w 0x025d ppsp r ppsp7 ppsp6 ppsp5 ppsp4 ppsp3 ppsp2 ppsp1 ppsp0 w 0x025e piep r piep7 piep6 piep5 piep4 piep3 piep2 piep1 piep0 w 0x025f pifp r pifp7 pifp6 pifp5 pifp4 pifp3 pifp2 pifp1 pifp0 w 0x0260?x0267 reserved r00000000 w 0x0268 ptj r ptj7 ptj6 ptj5 ptj4 ptj3 ptj2 ptj1 ptj0 w 0x0269 ptij r ptij7 ptij6 ptij5 ptij4 ptij3 ptij2 ptij1 ptij0 w 0x026a ddrj r ddrj7 ddrj6 ddrj5 ddrj4 ddrj3 ddrj2 ddrj1 ddrj0 w table 2-19. block register map ( g1 ) (continued) global address register name bit 7 654321 bit 0 = unimplemented or reserved
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 193 0x026b reserved r00000000 w 0x026c perj r perj7 perj6 perj5 perj4 perj3 perj2 perj1 perj0 w 0x026d ppsj r ppsj7 ppsj6 ppsj5 ppsj4 ppsj3 ppsj2 ppsj1 ppsj0 w 0x026e piej r piej7 piej6 piej5 piej4 piej3 piej2 piej1 piej0 w 0x026f pifj r pifj7 pifj6 pifj5 pifj4 pifj3 pifj2 pifj1 pifj0 w 0x0270 pt0ad r pt0ad7 pt0ad6 pt0ad5 pt0ad4 pt0ad3 pt0ad2 pt0ad1 pt0ad0 w 0x0271 pt1ad r pt1ad7 pt1ad6 pt1ad5 pt1ad4 pt1ad3 pt1ad2 pt1ad1 pt1ad0 w 0x0272 pti0ad r pti0ad7 pti0ad6 pti0ad5 pti0ad4 pti0ad3 pti0ad2 pti0ad1 pti0ad0 w 0x0273 pti1ad r pti1ad7 pti1ad6 pti1ad5 pti1ad4 pti1ad3 pti1ad2 pti1ad1 pti1ad0 w 0x0274 ddr0ad r ddr0ad7 ddr0ad6 ddr0ad5 ddr0ad4 ddr0ad3 ddr0ad2 ddr0ad1 ddr0ad0 w 0x0275 ddr1ad r ddr1ad7 ddr1ad6 ddr1ad5 ddr1ad4 ddr1ad3 ddr1ad2 ddr1ad1 ddr1ad0 w 0x0276 reserved r reserved for rvactl on g(a)240 and g(a)192 w 0x0277 prr1 r0000000 prr1an w 0x0278 per0ad r per0ad7 per0ad6 per0ad5 per0ad4 per0ad3 per0ad2 per0ad1 per0ad0 w 0x0279 per1ad r per1ad7 per1ad6 per1ad5 per1ad4 per1ad3 per1ad2 per1ad1 per1ad0 w table 2-19. block register map ( g1 ) (continued) global address register name bit 7 654321 bit 0 = unimplemented or reserved
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 194 freescale semiconductor 2.4.2.2 block register map ( g2 ) 0x027a pps0ad r pps0ad7 pps0ad6 pps0ad5 pps0ad4 pps0ad3 pps0ad2 pps0ad1 pps0ad0 w 0x027b pps1ad r pps1ad7 pps1ad6 pps1ad5 pps1ad4 pps1ad3 pps1ad2 pps1ad1 pps1ad0 w 0x027c pie0ad r pie0ad7 pie0ad6 pie0ad5 pie0ad4 pie0ad3 pie0ad2 pie0ad1 pie0ad0 w 0x027d pie1ad r pie1ad7 pie1ad6 pie1ad5 pie1ad4 pie1ad3 pie1ad2 pie1ad1 pie1ad0 w 0x027e pif0ad r pif0ad7 pif0ad6 pif0ad5 pif0ad4 pif0ad3 pif0ad2 pif0ad1 pif0ad0 w 0x027f pif1ad r pif1ad7 pif1ad6 pif1ad5 pif1ad4 pif1ad3 pif1ad2 pif1ad1 pif1ad0 w table 2-20. block register map ( g2 ) global address register name bit 7 654321 bit 0 0x0000?x0007 reserved r00000000 w 0x0008 porte r000000 pe1 pe0 w 0x0009 ddre r000000 ddre1 ddre0 w 0x000a?x000b non-pim address range r non-pim address range w 0x000c pucr r0 bkpue 0 pdpee 0000 w 0x000d reserved r00000000 w = unimplemented or reserved table 2-19. block register map ( g1 ) (continued) global address register name bit 7 654321 bit 0 = unimplemented or reserved
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 195 0x000e?x001b non-pim address range r non-pim address range w 0x001c eclkctl r neclk nclkx2 div16 ediv4 ediv3 ediv2 ediv1 ediv0 w 0x001d reserved r00000000 w 0x001e irqcr r irqe irqen 000000 w 0x001f reserved r reserved reserved reserved reserved reserved reserved reserved reserved w 0x0020?x023f non-pim address range r non-pim address range w 0x0240 ptt r ptt7 ptt6 ptt5 ptt4 ptt3 ptt2 ptt1 ptt0 w 0x0241 ptit r ptit7 ptit6 ptit5 ptit4 ptit3 ptit2 ptit1 ptit0 w 0x0242 ddrt r ddrt7 ddrt6 ddrt5 ddrt4 ddrt3 ddrt2 ddrt1 ddrt0 w 0x0243 reserved r00000000 w 0x0244 pert r pert7 pert6 pert5 pert4 pert3 pert2 pert1 pert0 w 0x0245 ppst r ppst7 ppst6 ppst5 ppst4 ppst3 ppst2 ppst1 ppst0 w 0x0246 reserved r00000000 w 0x0247 reserved r00000000 w 0x0248 pts r pts7 pts6 pts5 pts4 pts3 pts2 pts1 pts0 w table 2-20. block register map ( g2 ) (continued) global address register name bit 7 654321 bit 0 = unimplemented or reserved
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 196 freescale semiconductor 0x0249 ptis r ptis7 ptis6 ptis5 ptis4 ptis3 ptis2 ptis1 ptis0 w 0x024a ddrs r ddrs7 ddrs6 ddrs5 ddrs4 ddrs3 ddrs2 ddrs1 ddrs0 w 0x024b reserved r00000000 w 0x024c pers r pers7 pers6 pers5 pers4 pers3 pers2 pers1 pers0 w 0x024d ppss r ppss7 ppss6 ppss5 ppss4 ppss3 ppss2 ppss1 ppss0 w 0x024e woms r woms7 woms6 woms5 woms4 woms3 woms2 woms1 woms0 w 0x024f prr0 r prr0p3 prr0p2 prr0t31 prr0t30 prr0t21 prr0t20 prr0s1 prr0s0 w 0x0250 ptm r0000 ptm3 ptm2 ptm1 ptm0 w 0x0251 ptim r0000 ptim3 ptim2 ptim1 ptim0 w 0x0252 ddrm r0000 ddrm3 ddrm2 ddrm1 ddrm0 w 0x0253 reserved r00000000 w 0x0254 perm r0000 perm3 perm2 perm1 perm0 w 0x0255 ppsm r0000 ppsm3 ppsm2 ppsm1 ppsm0 w 0x0256 womm r0000 womm3 womm2 womm1 womm0 w 0x0257 pkgcr r apiclks7 0000 pkgcr2 pkgcr1 pkgcr0 w table 2-20. block register map ( g2 ) (continued) global address register name bit 7 654321 bit 0 = unimplemented or reserved
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 197 0x0258 ptp r ptp7 ptp6 ptp5 ptp4 ptp3 ptp2 ptp1 ptp0 w 0x0259 ptip r ptip7 ptip6 ptip5 ptip4 ptip3 ptip2 ptip1 ptip0 w 0x025a ddrp r ddrp7 ddrp6 ddrp5 ddrp4 ddrp3 ddrp2 ddrp1 ddrp0 w 0x025b reserved r00000000 w 0x025c perp r perp7 perp6 perp5 perp4 perp3 perp2 perp1 perp0 w 0x025d ppsp r ppsp7 ppsp6 ppsp5 ppsp4 ppsp3 ppsp2 ppsp1 ppsp0 w 0x025e piep r piep7 piep6 piep5 piep4 piep3 piep2 piep1 piep0 w 0x025f pifp r pifp7 pifp6 pifp5 pifp4 pifp3 pifp2 pifp1 pifp0 w 0x0260?x0261 reserved r reserved for acmp w 0x0262?x0266 reserved r00000000 w 0x0267 reserved r reserved reserved 00000 reserved w 0x0268 ptj r ptj7 ptj6 ptj5 ptj4 ptj3 ptj2 ptj1 ptj0 w 0x0269 ptij r ptij7 ptij6 ptij5 ptij4 ptij3 ptij2 ptij1 ptij0 w 0x026a ddrj r ddrj7 ddrj6 ddrj5 ddrj4 ddrj3 ddrj2 ddrj1 ddrj0 w 0x026b reserved r00000000 w table 2-20. block register map ( g2 ) (continued) global address register name bit 7 654321 bit 0 = unimplemented or reserved
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 198 freescale semiconductor 0x026c perj r perj7 perj6 perj5 perj4 perj3 perj2 perj1 perj0 w 0x026d ppsj r ppsj7 ppsj6 ppsj5 ppsj4 ppsj3 ppsj2 ppsj1 ppsj0 w 0x026e piej r piej7 piej6 piej5 piej4 piej3 piej2 piej1 piej0 w 0x026f pifj r pifj7 pifj6 pifj5 pifj4 pifj3 pifj2 pifj1 pifj0 w 0x0270 pt0ad r pt0ad7 pt0ad6 pt0ad5 pt0ad4 pt0ad3 pt0ad2 pt0ad1 pt0ad0 w 0x0271 pt1ad r pt1ad7 pt1ad6 pt1ad5 pt1ad4 pt1ad3 pt1ad2 pt1ad1 pt1ad0 w 0x0272 pti0ad r pti0ad7 pti0ad6 pti0ad5 pti0ad4 pti0ad3 pti0ad2 pti0ad1 pti0ad0 w 0x0273 pti1ad r pti1ad7 pti1ad6 pti1ad5 pti1ad4 pti1ad3 pti1ad2 pti1ad1 pti1ad0 w 0x0274 ddr0ad r ddr0ad7 ddr0ad6 ddr0ad5 ddr0ad4 ddr0ad3 ddr0ad2 ddr0ad1 ddr0ad0 w 0x0275 ddr1ad r ddr1ad7 ddr1ad6 ddr1ad5 ddr1ad4 ddr1ad3 ddr1ad2 ddr1ad1 ddr1ad0 w 0x0276 reserved r00000000 w 0x0277 reserved r00000000 w 0x0278 per0ad r per0ad7 per0ad6 per0ad5 per0ad4 per0ad3 per0ad2 per0ad1 per0ad0 w 0x0279 per1ad r per1ad7 per1ad6 per1ad5 per1ad4 per1ad3 per1ad2 per1ad1 per1ad0 w 0x027a pps0ad r pps0ad7 pps0ad6 pps0ad5 pps0ad4 pps0ad3 pps0ad2 pps0ad1 pps0ad0 w table 2-20. block register map ( g2 ) (continued) global address register name bit 7 654321 bit 0 = unimplemented or reserved
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 199 2.4.2.3 block register map ( g3 ) 0x027b pps1ad r pps1ad7 pps1ad6 pps1ad5 pps1ad4 pps1ad3 pps1ad2 pps1ad1 pps1ad0 w 0x027c pie0ad r pie0ad7 pie0ad6 pie0ad5 pie0ad4 pie0ad3 pie0ad2 pie0ad1 pie0ad0 w 0x027d pie1ad r pie1ad7 pie1ad6 pie1ad5 pie1ad4 pie1ad3 pie1ad2 pie1ad1 pie1ad0 w 0x027e pif0ad r pif0ad7 pif0ad6 pif0ad5 pif0ad4 pif0ad3 pif0ad2 pif0ad1 pif0ad0 w 0x027f pif1ad r pif1ad7 pif1ad6 pif1ad5 pif1ad4 pif1ad3 pif1ad2 pif1ad1 pif1ad0 w table 2-21. block register map ( g3 ) global address register name bit 7 654321 bit 0 0x0000?x0007 reserved r00000000 w 0x0008 porte r000000 pe1 pe0 w 0x0009 ddre r000000 ddre1 ddre0 w 0x000a?x000b non-pim address range r non-pim address range w 0x000c pucr r0 bkpue 0 pdpee 0000 w 0x000d reserved r00000000 w = unimplemented or reserved table 2-20. block register map ( g2 ) (continued) global address register name bit 7 654321 bit 0 = unimplemented or reserved
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 200 freescale semiconductor 0x000e?x001b non-pim address range r non-pim address range w 0x001c eclkctl r neclk nclkx2 div16 ediv4 ediv3 ediv2 ediv1 ediv0 w 0x001d reserved r00000000 w 0x001e irqcr r irqe irqen 000000 w 0x001f reserved r reserved reserved reserved reserved reserved reserved reserved reserved w 0x0020?x023f non-pim address range r non-pim address range w 0x0240 ptt r0 0 ptt5 ptt4 ptt3 ptt2 ptt1 ptt0 w 0x0241 ptit r 0 0 ptit5 ptit4 ptit3 ptit2 ptit1 ptit0 w 0x0242 ddrt r0 0 ddrt5 ddrt4 ddrt3 ddrt2 ddrt1 ddrt0 w 0x0243 reserved r00000000 w 0x0244 pert r0 0 pert5 pert4 pert3 pert2 pert1 pert0 w 0x0245 ppst r0 0 ppst5 ppst4 ppst3 ppst2 ppst1 ppst0 w 0x0246 reserved r00000000 w 0x0247 reserved r00000000 w 0x0248 pts r pts7 pts6 pts5 pts4 pts3 pts2 pts1 pts0 w table 2-21. block register map ( g3 ) (continued) global address register name bit 7 654321 bit 0 = unimplemented or reserved
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 201 0x0249 ptis r ptis7 ptis6 ptis5 ptis4 ptis3 ptis2 ptis1 ptis0 w 0x024a ddrs r ddrs7 ddrs6 ddrs5 ddrs4 ddrs3 ddrs2 ddrs1 ddrs0 w 0x024b reserved r00000000 w 0x024c pers r pers7 pers6 pers5 pers4 pers3 pers2 pers1 pers0 w 0x024d ppss r ppss7 ppss6 ppss5 ppss4 ppss3 ppss2 ppss1 ppss0 w 0x024e woms r woms7 woms6 woms5 woms4 woms3 woms2 woms1 woms0 w 0x024f prr0 r prr0p3 prr0p2 prr0t31 prr0t30 prr0t21 prr0t20 prr0s1 prr0s0 w 0x0250 ptm r000000 ptm1 ptm0 w 0x0251 ptim r000000 ptim1 ptim0 w 0x0252 ddrm r000000 ddrm1 ddrm0 w 0x0253 reserved r00000000 w 0x0254 perm r000000 perm1 perm0 w 0x0255 ppsm r000000 ppsm1 ppsm0 w 0x0256 womm r000000 womm1 womm0 w 0x0257 pkgcr r apiclks7 0000 pkgcr2 pkgcr1 pkgcr0 w table 2-21. block register map ( g3 ) (continued) global address register name bit 7 654321 bit 0 = unimplemented or reserved
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 202 freescale semiconductor 0x0258 ptp r0 0 ptp5 ptp4 ptp3 ptp2 ptp1 ptp0 w 0x0259 ptip r 0 0 ptip5 ptip4 ptip3 ptip2 ptip1 ptip0 w 0x025a ddrp r0 0 ddrp5 ddrp4 ddrp3 ddrp2 ddrp1 ddrp0 w 0x025b reserved r00000000 w 0x025c perp r0 0 perp5 perp4 perp3 perp2 perp1 perp0 w 0x025d ppsp r0 0 ppsp5 ppsp4 ppsp3 ppsp2 ppsp1 ppsp0 w 0x025e piep r0 0 piep5 piep4 piep3 piep2 piep1 piep0 w 0x025f pifp r0 0 pifp5 pifp4 pifp3 pifp2 pifp1 pifp0 w 0x0260?x0261 reserved r reserved for acmp w 0x0262?x0267 reserved r00000000 w 0x0268 ptj r0000 ptj3 ptj2 ptj1 ptj0 w 0x0269 ptij r0000 ptij3 ptij2 ptij1 ptij0 w 0x026a ddrj r0000 ddrj3 ddrj2 ddrj1 ddrj0 w 0x026b reserved r00000000 w 0x026c perj r0000 perj3 perj2 perj1 perj0 w table 2-21. block register map ( g3 ) (continued) global address register name bit 7 654321 bit 0 = unimplemented or reserved
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 203 0x026d ppsj r0000 ppsj3 ppsj2 ppsj1 ppsj0 w 0x026e piej r0000 piej3 piej2 piej1 piej0 w 0x026f pifj r0000 pifj3 pifj2 pifj1 pifj0 w 0x0270 pt0ad r0000 pt0ad3 pt0ad2 pt0ad1 pt0ad0 w 0x0271 pt1ad r pt1ad7 pt1ad6 pt1ad5 pt1ad4 pt1ad3 pt1ad2 pt1ad1 pt1ad0 w 0x0272 pti0ad r0000 pti0ad3 pti0ad2 pti0ad1 pti0ad0 w 0x0273 pti1ad r pti1ad7 pti1ad6 pti1ad5 pti1ad4 pti1ad3 pti1ad2 pti1ad1 pti1ad0 w 0x0274 ddr0ad r0000 ddr0ad3 ddr0ad2 ddr0ad1 ddr0ad0 w 0x0275 ddr1ad r ddr1ad7 ddr1ad6 ddr1ad5 ddr1ad4 ddr1ad3 ddr1ad2 ddr1ad1 ddr1ad0 w 0x0276 reserved r00000000 w 0x0277 reserved r00000000 w 0x0278 per0ad r0000 per0ad3 per0ad2 per0ad1 per0ad0 w 0x0279 per1ad r per1ad7 per1ad6 per1ad5 per1ad4 per1ad3 per1ad2 per1ad1 per1ad0 w 0x027a pps0ad r0000 pps0ad3 pps0ad2 pps0ad1 pps0ad0 w 0x027b pps1ad r pps1ad7 pps1ad6 pps1ad5 pps1ad4 pps1ad3 pps1ad2 pps1ad1 pps1ad0 w table 2-21. block register map ( g3 ) (continued) global address register name bit 7 654321 bit 0 = unimplemented or reserved
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 204 freescale semiconductor 2.4.3 register descriptions this section describes the details of all con?uration registers. every register has the same functionality in all groups if not speci?d separately. refer to the register ?ures for reserved locations. if not stated differently, writing to reserved bits has not effect and read returns zero. note all register read accesses are synchronous to internal clocks general-purpose data output availability depends on prioritization; input data registers always re?ct the pin status independent of the use pull-device availability, pull-device polarity, wired-or mode, key-wakeup functionality are independent of the prioritization unless noted differently in section section 2.3, ?im routing - functional description ? 0x027c pie0ad r0000 pie0ad3 pie0ad2 pie0ad1 pie0ad0 w 0x027d pie1ad r pie1ad7 pie1ad6 pie1ad5 pie1ad4 pie1ad3 pie1ad2 pie1ad1 pie1ad0 w 0x027e pif0ad r0000 pif0ad3 pif0ad2 pif0ad1 pif0ad0 w 0x027f pif1ad r pif1ad7 pif1ad6 pif1ad5 pif1ad4 pif1ad3 pif1ad2 pif1ad1 pif1ad0 w table 2-21. block register map ( g3 ) (continued) global address register name bit 7 654321 bit 0 = unimplemented or reserved
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 205 2.4.3.1 port a data register (porta) 2.4.3.2 port b data register (portb) address 0x0000 ( g1 ) access: user read/write 1 1 read: anytime. the data source is depending on the data direction value. write: anytime 76543210 r pa 7 pa 6 pa 5 pa4 pa3 pa2 pa1 pa0 w reset 0 0000000 address 0x0000 ( g2 , g3 ) access: user read only 76543210 r00000000 w reset 0 0000000 figure 2-2. port a data register (porta) table 2-22. porta register field descriptions field description 7-0 pa port a general-purpose input/output data ?ata register the associated pin can be used as general-purpose i/o. in general-purpose output mode the port data register bit value is driven to the pin. if the associated data direction bit is set to 1, a read returns the value of the port data register bit, otherwise the buffered pin input state is read. address 0x0001 ( g1 ) access: user read/write 1 76543210 r pb7 pb6 pb5 pb4 pb3 pb2 pb1 pb0 w reset 0 0000000 address 0x0001 ( g2 , g3 ) access: user read only 76543210 r00000000 w reset 0 0000000 figure 2-3. port b data register (portb)
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 206 freescale semiconductor 2.4.3.3 port a data direction register (ddra) 1 read: anytime. the data source is depending on the data direction value. write: anytime table 2-23. portb register field descriptions field description 7-0 pb port b general-purpose input/output data ?ata register the associated pin can be used as general-purpose i/o. in general-purpose output mode the port data register bit value is driven to the pin. if the associated data direction bit is set to 1, a read returns the value of the port data register bit, otherwise the buffered pin input state is read. address 0x0002 ( g1 ) access: user read/write 1 1 read: anytime write: anytime 76543210 r ddra7 ddra6 ddra5 ddra4 ddra3 ddra2 ddra1 ddra0 w reset 0 0000000 address 0x0002 ( g2 , g3 ) access: user read only 76543210 r00000000 w reset 0 0000000 figure 2-4. port a data direction register (ddra) table 2-24. ddra register field descriptions field description 7-0 ddra port a data direction this bit determines whether the associated pin is an input or output. 1 associated pin con?ured as output 0 associated pin con?ured as input
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 207 2.4.3.4 port b data direction register (ddrb) 2.4.3.5 port c data register (portc) address 0x0003 ( g1 ) access: user read/write 1 1 read: anytime write: anytime 76543210 r ddrb7 ddrb6 ddrb5 ddrb4 ddrb3 ddrb2 ddrb1 ddrb0 w reset 0 0000000 address 0x0003 ( g2 , g3 ) access: user read only 76543210 r00000000 w reset 0 0000000 figure 2-5. port b data direction register (ddrb) table 2-25. ddrb register field descriptions field description 7-0 ddrb port b data direction this bit determines whether the associated pin is an input or output. 1 associated pin con?ured as output 0 associated pin con?ured as input address 0x0004 ( g1 ) access: user read/write 1 1 read: anytime. the data source is depending on the data direction value. write: anytime 76543210 r pc7 pc6 pc5 pc4 pc3 pc2 pc1 pc0 w reset 0 0000000 address 0x0004 ( g2 , g3 ) access: user read only 76543210 r00000000 w reset 0 0000000 figure 2-6. port c data register (portc)
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 208 freescale semiconductor 2.4.3.6 port d data register (portd) table 2-26. portc register field descriptions field description 7-0 pc port c general-purpose input/output data ?ata register the associated pin can be used as general-purpose i/o. in general-purpose output mode the port data register bit value is driven to the pin. if the associated data direction bit is set to 1, a read returns the value of the port data register bit, otherwise the buffered pin input state is read. address 0x0005 ( g1 ) access: user read/write 1 1 read: anytime. the data source is depending on the data direction value. write: anytime 76543210 r pd7 pd6 pd5 pd4 pd3 pd2 pd1 pd0 w reset 0 0000000 address 0x0005 ( g2 , g3 ) access: user read only 76543210 r00000000 w reset 0 0000000 figure 2-7. port d data register (portd) table 2-27. portd register field descriptions field description 7-0 pd port d general-purpose input/output data ?ata register the associated pin can be used as general-purpose i/o. in general-purpose output mode the port data register bit value is driven to the pin. if the associated data direction bit is set to 1, a read returns the value of the port data register bit, otherwise the buffered pin input state is read.
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 209 2.4.3.7 port c data direction register (ddrc) 2.4.3.8 port d data direction register (ddrd) address 0x0006 ( g1 ) access: user read/write 1 1 read: anytime write: anytime 76543210 r ddrc7 ddrc6 ddrc5 ddra4 ddrc3 ddrc2 ddrc1 ddrc0 w reset 0 0000000 address 0x0006 ( g2 , g3 ) access: user read only 76543210 r00000000 w reset 0 0000000 figure 2-8. port c data direction register (ddrc) table 2-28. ddrc register field descriptions field description 7-0 ddrc port c data direction this bit determines whether the associated pin is an input or output. 1 associated pin con?ured as output 0 associated pin con?ured as input address 0x0007 ( g1 ) access: user read/write 1 1 read: anytime write: anytime 76543210 r ddrd7 ddrd6 ddrd5 ddrd4 ddrd3 ddrd2 ddrd1 ddrd0 w reset 0 0000000 address 0x0007 ( g2 , g3 ) access: user read only 76543210 r00000000 w reset 0 0000000 figure 2-9. port d data direction register (ddrd)
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 210 freescale semiconductor 2.4.3.9 port e data register (porte) 2.4.3.10 port e data direction register (ddre) table 2-29. ddrd register field descriptions field description 7-0 ddrd port d data direction this bit determines whether the associated pin is an input or output. 1 associated pin con?ured as output 0 associated pin con?ured as input address 0x0008 access: user read/write 1 1 read: anytime. the data source is depending on the data direction value. write: anytime 76543210 r000000 pe1 pe0 w reset 00000000 figure 2-10. port e data register (porte) table 2-30. porte register field descriptions field description 1-0 pe port e general-purpose input/output data ?ata register when not used with an alternative signal, this pin can be used as general-purpose i/o. in general-purpose output mode the port data register bit is driven to the pin. if the associated data direction bit of this pin is set to 1, a read returns the value of the port register, otherwise the buffered pin input state is read. address 0x0009 access: user read/write 1 1 read: anytime write: anytime 76543210 r000000 ddre1 ddre0 w reset 00000000 figure 2-11. port e data direction register (ddre)
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 211 2.4.3.11 ports a, b, c, d, e, bkgd pin pull control register (pucr) table 2-31. ddre register field descriptions field description 1-0 ddre port e data direction this bit determines whether the associated pin is an input or output. 1 associated pin con?ured as output 0 associated pin con?ured as input address 0x000c ( g1 ) access: user read/write 1 1 read:anytime in normal mode. write:anytime, except bkpue, which is writable in special mode only. 76543210 r0 bkpue 0 pdpee pupde pupce pupbe pupae w reset 0 1010000 address 0x000c ( g2 , g3 ) access: user read/write 76543210 r0 bkpue 0 pdpee 0000 w reset 0 1010000 figure 2-12. ports a, b, c, d, e, bkgd pin pullup control register (pucr) table 2-32. pucr register field descriptions field description 6 bkpue bkgd pin pullup enable ?nable pullup device on pin this bit con?ures whether a pullup device is activated, if the pin is used as input. if a pin is used as output this bit has no effect. out of reset the pullup device is enabled. 1 pullup device enabled 0 pullup device disabled 4 pdpee port e pulldown enable ?nable pulldown devices on all port input pins this bit con?ures whether a pulldown device is activated on all associated port input pins. if a pin is used as output or used with the cpmu osc function this bit has no effect. out of reset the pulldown devices are enabled. 1 pulldown devices enabled 0 pulldown devices disabled 3 pupde port d pullup enable ?nable pullup devices on all port input pins this bit con?ures whether a pullup device is activated on all associated port input pins. if a pin is used as output this bit has no effect. 1 pullup devices enabled 0 pullup devices disabled
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 212 freescale semiconductor 2 pupce port c pullup enable ?nable pullup devices on all port input pins this bit con?ures whether a pullup device is activated on all associated port input pins. if a pin is used as output this bit has no effect. 1 pullup devices enabled 0 pullup devices disabled 1 pupbe port b pullup enable ?nable pullup devices on all port input pins this bit con?ures whether a pullup device is activated on all associated port input pins. if a pin is used as output this bit has no effect. 1 pullup devices enabled 0 pullup devices disabled 0 pupae port a pullup enable ?nable pullup devices on all port input pins this bit con?ures whether a pullup device is activated on all associated port input pins. if a pin is used as output this bit has no effect. 1 pullup devices enabled 0 pullup devices disabled table 2-32. pucr register field descriptions (continued) field description
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 213 2.4.3.12 eclk control register (eclkctl) 2.4.3.13 irq control register (irqcr) address 0x001c access: user read/write 1 1 read: anytime write: anytime 76543210 r neclk nclkx2 div16 ediv4 ediv3 ediv2 ediv1 ediv0 w reset: 11000000 figure 2-13. eclk control register (eclkctl) table 2-33. eclkctl register field descriptions field description 7 neclk no eclk ?isable eclk output this bit controls the availability of a free-running clock on the eclk pin. this clock has a xed rate equivalent to the internal bus clock. 1 eclk disabled 0 eclk enabled 6 nclkx2 no eclkx2 ?isable eclkx2 output this bit controls the availability of a free-running clock on the eclkx2 pin. this clock has a ?ed rate of twice the internal bus clock. 1 eclkx2 disabled 0 eclkx2 enabled 5 div16 free-running eclk predivider ?ivide by 16 this bit enables a divide-by-16 stage on the selected ediv rate. 1 divider enabled: eclk rate = ediv rate divided by 16 0 divider disabled: eclk rate = ediv rate 4-0 ediv free-running eclk divider ?on?ure eclk rate these bits determine the rate of the free-running clock on the eclk pin. 00000 eclk rate = bus clock rate 00001 eclk rate = bus clock rate divided by 2 00010 eclk rate = bus clock rate divided by 3,... 11111 eclk rate = bus clock rate divided by 32 address 0x001e access: user read/write 1 76543210 r irqe irqen 000000 w reset 00000000 figure 2-14. irq control register (irqcr)
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 214 freescale semiconductor note if the input is driven to active level ( irq=0) a write access to set either irqcr[irqen] and irqcr[irqe] to 1 simultaneously or to set irqcr[irqen] to 1 when irqcr[irqe]=1 causes an irq interrupt to be generated if the i-bit is cleared. refer to section 2.6.3, ?nabling irq edge-sensitive mode ? 2.4.3.14 reserved register 1 read: anytime write: irqe: once in normal mode, anytime in special mode irqen: anytime table 2-34. irqcr register field descriptions field description 7 irqe irq select edge sensitive only 1 irq pin con?ured to respond only to falling edges. falling edges on the irq pin are detected anytime when irqe=1 and will be cleared only upon a reset or the servicing of the irq interrupt. 0 irq pin con?ured for low level recognition 6 irqen irq enable 1 irq pin is connected to interrupt logic 0 irq pin is disconnected from interrupt logic address 0x001f access: user read/write 1 1 read: anytime write: only in special mode these reserved registers are designed for factory test purposes only and are not intended for general user access. writing to these registers when in special mode can alter the modules functionality. 76543210 r reserved reserved reserved reserved reserved reserved reserved reserved w reset xxxxxxxx figure 2-15. reserved register
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 215 2.4.3.15 port t data register (ptt) 2.4.3.16 port t input register (ptit) address 0x0240 ( g1 , g2 ) access: user read/write 1 1 read: anytime. the data source is depending on the data direction value. write: anytime 76543210 r ptt7 ptt6 ptt5 ptt4 ptt3 ptt2 ptt1 ptt0 w reset 00000000 address 0x0240 ( g3 ) access: user read/write 1 76543210 r 0 0 ptt5 ptt4 ptt3 ptt2 ptt1 ptt0 w reset 00000000 figure 2-16. port t data register (ptt) table 2-35. ptt register field descriptions field description 7-0 ptt port t general-purpose input/output data ?ata register when not used with an alternative signal, the associated pin can be used as general-purpose i/o. in general-purpose output mode the port data register bit value is driven to the pin. if the associated data direction bit is set to 1, a read returns the value of the port data register bit, otherwise the buffered pin input state is read. address 0x0241 ( g1 , g2 ) access: user read only 1 1 read: anytime write:never 76543210 r ptit7 ptit6 ptit5 ptit4 ptit3 ptit2 ptit1 ptit0 w reset 00000000 address 0x0241 ( g3 ) access: user read only 1 76543210 r 0 0 ptit5 ptit4 ptit3 ptit2 ptit1 ptit0 w reset 00000000 figure 2-17. port t input register (ptit)
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 216 freescale semiconductor 2.4.3.17 port t data direction register (ddrt) table 2-36. ptit register field descriptions field description 7-0 ptit port t input data a read always returns the buffered input state of the associated pin. it can be used to detect overload or short circuit conditions on output pins. address 0x0242 ( g1 , g2 ) access: user read/write 1 1 read: anytime write: anytime 76543210 r ddrt7 ddrt6 ddrt5 ddrt4 ddrt3 ddrt2 ddrt1 ddrt0 w reset 00000000 address 0x0242 ( g3 ) access: user read/write 1 76543210 r 0 0 ddrt5 ddrt4 ddrt3 ddrt2 ddrt1 ddrt0 w reset 00000000 figure 2-18. port t data direction register (ddrt) table 2-37. ddrt register field descriptions field description 7-0 ddrt port t data direction this bit determines whether the pin is a general-purpose input or output. 1 associated pin con?ured as output 0 associated pin con?ured as input
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 217 2.4.3.18 port t pull device enable register (pert) address 0x0244 ( g1 , g2 ) access: user read/write 1 1 read: anytime write: anytime 76543210 r pert7 pert6 pert5 pert4 pert3 pert2 pert1 pert0 w reset 00000000 address 0x0244 ( g3 ) access: user read/write 1 76543210 r0 0 pert5 pert4 pert3 pert2 pert1 pert0 w reset 00000000 figure 2-19. port t pull device enable register (pert) table 2-38. pert register field descriptions field description 7-2 pert port t pull device enable ?nable pull device on input pin this bit controls whether a pull device on the associated port input pin is active. if a pin is used as output this bit has no effect. the polarity is selected by the related polarity select register bit. 1 pull device enabled 0 pull device disabled 1 pert port t pull device enable ?nable pull device on input pin this bit controls whether a pull device on the associated port input pin is active. the polarity is selected by the related polarity select register bit. if this pin is used as irq only a pullup device can be enabled. 1 pull device enabled 0 pull device disabled 0 pert port t pull device enable ?nable pull device on input pin this bit controls whether a pull device on the associated port input pin is active. the polarity is selected by the related polarity select register bit. if this pin is used as xirq only a pullup device can be enabled. 1 pull device enabled 0 pull device disabled
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 218 freescale semiconductor 2.4.3.19 port t polarity select register (ppst) 2.4.3.20 port s data register (pts) address 0x0245 ( g1 , g2 ) access: user read/write 1 1 read: anytime write: anytime 76543210 r ppst7 ppst6 ppst5 ppst4 ppst3 ppst2 ppst1 ppst0 w reset 00000000 address 0x0245 ( g3 ) access: user read/write 1 76543210 r0 0 ppst5 ppst4 ppst3 ppst2 ppst1 ppst0 w reset 00000000 figure 2-20. port t polarity select register (ppst) table 2-39. ppst register field descriptions field description 7-0 ppst port t pull device select ?on?ure pull device polarity on input pin this bit selects a pullup or a pulldown device if enabled on the associated port input pin. 1 pulldown device selected 0 pullup device selected address 0x0248 access: user read/write 1 1 read: anytime. the data source is depending on the data direction value. write: anytime 76543210 r pts7 pts6 pts5 pts4 pts3 pts2 pts1 pts0 w 00000000 figure 2-21. port s data register (pts)
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 219 2.4.3.21 port s input register (ptis) 2.4.3.22 port s data direction register (ddrs) table 2-40. pts register field descriptions field description 7-0 pts port s general-purpose input/output data ?ata register when not used with an alternative signal, the associated pin can be used as general-purpose i/o. in general-purpose output mode the port data register bit value is driven to the pin. if the associated data direction bit is set to 1, a read returns the value of the port data register bit, otherwise the buffered pin input state is read. address 0x0249 access: user read only 1 1 read: anytime write:never 76543210 r ptis7 ptis6 ptis5 ptis4 ptis3 ptis2 ptis1 ptis0 w reset 00000000 figure 2-22. port s input register (ptis) table 2-41. ptis register field descriptions field description 7-0 ptis port s input data a read always returns the buffered input state of the associated pin. it can be used to detect overload or short circuit conditions on output pins. address 0x024a access: user read/write 1 1 read: anytime write: anytime 76543210 r ddrs7 ddrs6 ddrs5 ddrs4 ddrs3 ddrs2 ddrs1 ddrs0 w reset 00000000 figure 2-23. port s data direction register (ddrs)
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 220 freescale semiconductor 2.4.3.23 port s pull device enable register (pers) 2.4.3.24 port s polarity select register (ppss) table 2-42. ddrs register field descriptions field description 7-0 ddrs port s data direction this bit determines whether the associated pin is a general-purpose input or output. 1 associated pin con?ured as output 0 associated pin con?ured as input address 0x024c access: user read/write 1 1 read: anytime write: anytime 76543210 r pers7 pers6 pers5 pers4 pers3 pers2 pers1 pers0 w reset 11111111 figure 2-24. port s pull device enable register (pers) table 2-43. pers register field descriptions field description 7-0 pers port s pull device enable ?nable pull device on input pin or wired-or output pin this bit controls whether a pull device on the associated port input pin is active. the polarity is selected by the related polarity select register bit. if a pin is used as output this bit has only effect if used in wired-or mode with a pullup device. 1 pull device enabled 0 pull device disabled address 0x024d access: user read/write 1 1 read: anytime write: anytime 76543210 r ppss7 ppss6 ppss5 ppss4 ppss3 ppss2 ppss1 ppss0 w reset 00000000 figure 2-25. port s polarity select register (ppss)
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 221 2.4.3.25 port s wired-or mode register (woms) 2.4.3.26 pin routing register 0 (prr0) note routing takes only effect if pkgcr is set to select the 20 tssop package. table 2-44. ppss register field descriptions field description 7-0 ppss port s pull device select ?on?ure pull device polarity on input pin this bit selects a pullup or a pulldown device if enabled on the associated port input pin. 1 pulldown device selected 0 pullup device selected address 0x024e access: user read/write 1 1 read: anytime write: anytime 76543210 r woms7 woms6 woms5 woms4 woms3 woms2 woms1 woms0 w reset 00000000 figure 2-26. port s wired-or mode register (woms) table 2-45. woms register field descriptions field description 7-0 woms port s wired-or mode ?nable open-drain functionality on output pin this bit con?ures an output pin as wired-or (open-drain) or push-pull. in wired-or mode a logic ??is driven active-low while a logic ? remains undriven. this allows a multipoint connection of several serial modules. the bit has no in?ence on pins used as input. 1 output buffer operates as open-drain output. 0 output buffer operates as push-pull output. address 0x024f access: user read/write 1 1 read: anytime write: anytime 76543210 r prr0p3 prr0p2 prr0t31 prr0t30 prr0t21 prr0t20 prr0s1 prr0s0 w reset 00000000 figure 2-27. pin routing register (prr0)
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 222 freescale semiconductor table 2-46. prr0 register field descriptions field description 7 prr0p3 pin routing register pwm3 ?elect alternative routing of pwm3 output, etrig3 input this bit programs the routing of the pwm3 channel and the etrig3 input to a different external pin in 20 tssop. see table 2-47 for more details. 6 prr0p2 pin routing register pwm2 ?elect alternative routing of pwm2 output, etrig2 input this bit programs the routing of the pwm2 channel and the etrig2 input to a different external pin in 20 tssop. see table 2-48 for more details. 5 prr0t31 pin routing register ioc3 ?elect alternative routing of ioc3 output and input those two bits program the routing of the timer ioc3 channel to different external pins in 20 tssop. see table 2-49 for more details. 4 prr0t30 3 prr0t21 pin routing register ioc2 ?elect alternative routing of ioc2 output and input those two bits program the routing of the timer ioc2 channel to different external pins in 20 tssop. see table 2-50 for more details. 2 prr0t20 1 prr0s1 pin routing register serial module ?elect alternative routing of sci0 pins those bits program the routing of the sci0 module pins to different external pins in 20 tssop. see table 2-51 for more details. 0 prr0s0 table 2-47. pwm3/etrig3 routing options prr0p3 pwm3/etrig3 associated pin 0 ps7 - pwm3, etrig3 1 pad5 - pwm3, etrig3 table 2-48. pwm2/etrig2 routing options prr0p2 pwm2/etrig2 associated pin 0 ps4 - pwm2, etrig2 1 pad4 - pwm2, etrig2 table 2-49. ioc3 routing options prr0t31 prr0t30 ioc3 associated pin 0 0 ps6 - ioc3 0 1 pe1 - ioc3 1 0 pad5 - ioc3 1 1 reserved
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 223 2.4.3.27 port m data register (ptm) table 2-50. ioc2 routing options prr0t21 prr0t20 ioc2 associated pin 0 0 ps5 - ioc2 0 1 pe0 - ioc2 1 0 pad4 - ioc2 1 1 reserved table 2-51. sci0 routing options prr0s1 prr0s0 sci0 associated pin 0 0 pe0 - rxd, pe1 - txd 0 1 ps4 - rxd, ps7 - txd 1 0 pad4 - rxd, pad5 - txd 1 1 reserved address 0x0250 ( g1 , g2 ) access: user read/write 1 1 read: anytime. the data source is depending on the data direction value. write: anytime 76543210 r0000 ptm3 ptm2 ptm1 ptm0 w reset 00000000 address 0x0250 ( g3 ) access: user read/write 1 76543210 r000000 ptm1 ptm0 w reset 00000000 figure 2-28. port m data register (ptm) table 2-52. ptm register field descriptions field description 3-0 ptm port m general-purpose input/output data ?ata register when not used with an alternative signal, the associated pin can be used as general-purpose i/o. in general-purpose output mode the port data register bit value is driven to the pin. if the associated data direction bit is set to 1, a read returns the value of the port data register bit, otherwise the buffered pin input state is read.
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 224 freescale semiconductor 2.4.3.28 port m input register (ptim) 2.4.3.29 port m data direction register (ddrm) address 0x0251 ( g1 , g2 ) access: user read only 1 1 read: anytime write:never 76543210 r0000 ptim3 ptim2 ptim1 ptim0 w reset 00000000 address 0x0251 ( g3 ) access: user read only 1 76543210 r000000 ptim1 ptim0 w reset 00000000 figure 2-29. port m input register (ptim) table 2-53. ptim register field descriptions field description 3-0 ptim port m input data a read always returns the buffered input state of the associated pin. it can be used to detect overload or short circuit conditions on output pins. address 0x0252 ( g1 , g2 ) access: user read/write 1 1 read: anytime write: anytime 76543210 r0000 ddrm3 ddrm2 ddrm1 ddrm0 w reset 00000000 address 0x0252 ( g3 ) access: user read/write 1 76543210 r000000 ddrm1 ddrm0 w reset 00000000 figure 2-30. port m data direction register (ddrm)
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 225 2.4.3.30 port m pull device enable register (perm) table 2-54. ddrm register field descriptions field description 3-0 ddrm port m data direction this bit determines whether the associated pin is a general-purpose input or output. 1 associated pin con?ured as output 0 associated pin con?ured as input address 0x0254 ( g1 , g2 ) access: user read/write 1 1 read: anytime write: anytime 76543210 r0000 perm3 perm2 perm1 perm0 w reset 00000000 address 0x0254 ( g3 ) access: user read/write 1 76543210 r000000 perm1 perm0 w reset 00000000 figure 2-31. port m pull device enable register (perm) table 2-55. perm register field descriptions field description 3-1 perm port m pull device enable ?nable pull device on input pin or wired-or output pin this bit controls whether a pull device on the associated port input pin is active. the polarity is selected by the related polarity select register bit. if a pin is used as output this bit has only effect if used in wired-or mode with a pullup device. 1 pull device enabled 0 pull device disabled 0 perm port m pull device enable ?nable pull device on input pin or wired-or output pin this bit controls whether a pull device on the associated port input pin is active. the polarity is selected by the related polarity select register bit. if a pin is used as output this bit has only effect if used in wired-or mode with a pullup device. if can is active the selection of a pulldown device on the rxcan input will have no effect. 1 pull device enabled 0 pull device disabled
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 226 freescale semiconductor 2.4.3.31 port m polarity select register (ppsm) 2.4.3.32 port m wired-or mode register (womm) address 0x0255 ( g1 , g2 ) access: user read/write 1 1 read: anytime write: anytime 76543210 r0000 ppsm3 ppsm2 ppsm1 ppsm0 w reset 00000000 address 0x0255 ( g3 ) access: user read/write 1 76543210 r000000 ppsm1 ppsm0 w reset 00000000 figure 2-32. port m polarity select register (ppsm) table 2-56. ppsm register field descriptions field description 3-0 ppsm port m pull device select ?on?ure pull device polarity on input pin this bit selects a pullup or a pulldown device if enabled on the associated port input pin. 1 pulldown device selected 0 pullup device selected address 0x0256 ( g1 , g2 ) access: user read/write 1 1 read: anytime write: anytime 76543210 r0000 womm3 womm2 womm1 womm0 w reset 00000000 address 0x0256 ( g3 ) access: user read/write 1 76543210 r000000 womm1 womm0 w reset 00000000 figure 2-33. port m wired-or mode register (womm)
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 227 2.4.3.33 package code register (pkgcr) table 2-57. womm register field descriptions field description 3-0 womm port m wired-or mode ?nable open-drain functionality on output pin this bit con?ures an output pin as wired-or (open-drain) or push-pull. in wired-or mode a logic ??is driven active-low while a logic ? remains undriven. this allows a multipoint connection of several serial modules. the bit has no in?ence on pins used as input. 1 output buffer operates as open-drain output. 0 output buffer operates as push-pull output. address 0x0257 access: user read/write 1 1 read: anytime write: apiclks7: anytime pkgcr2-0: once in normal mode, anytime in special mode 76543210 r apiclks7 0000 pkgcr2 pkgcr1 pkgcr0 w reset 00000fff after deassert of system reset the values are automatically loaded from the flash memory. see device speci?ation for details. figure 2-34. package code register (pkgcr) table 2-58. pkgcr register field descriptions field description 7 apiclks7 pin routing register api_extclk ?elect ps7 as api_extclk output when set to 1 the api_extclk output will be routed to ps7. the default pin will be disconnected in all packages except 20 tssop, which has no default location for api_extclk. see table 2-59 for more details. 2-0 pkgcr package code register ?elect package in use those bits are preset by factory and re?ct the package in use. see table 2-60 for code de?ition. the bits can be modi?d once after reset to allow software development for a different package. in any other application it is recommended to re-write the actual package code once after reset to lock the register from inadvertent changes during operation. writing reserved codes or codes of larger packages than the given device is offered in are illegal. in these cases the code will be converted to pkgcr[2:0]=0b111 and select the maximum available package option for the given device. codes writes of smaller packages than the given device is offered in are not restricted. depending on the package selection the input buffers of non-bonded pins are disabled to avoid shoot-through current. also a prede?ed signal routing will take effect. refer also to section 2.6.5, ?mulation of smaller packages ?
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 228 freescale semiconductor 2.4.3.34 port p data register (ptp) table 2-59. api_extclk routing options apiclks7 api_extclk associated pin 0 pb1 (100 lqfp) pp0 (64/48/32 lqfp) n.c. (20tssop) 1 ps7 table 2-60. package options pkgcr2 pkgcr1 pkgcr0 selected package 1 1 1 reserved 1 1 reading this value indicates an illegal code write or uninitialized factory programming. 1 1 0 100 lqfp 1 0 1 reserved 1 0 0 64 lqfp 0 1 1 48 lqfp 0 1 0 reserved 0 0 1 32 lqfp 0 0 0 20 tssop address 0x0258 ( g1 , g2 ) access: user read/write 1 1 read: anytime. the data source is depending on the data direction value. write: anytime 76543210 r ptp7 ptp6 ptp5 ptp4 ptp3 ptp2 ptp1 ptp0 w reset 00000000 address 0x0258 ( g3 ) access: user read/write 1 76543210 r0 0 ptp5 ptp4 ptp3 ptp2 ptp1 ptp0 w reset 00000000 figure 2-35. port p data register (ptp)
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 229 2.4.3.35 port p input register (ptip) table 2-61. ptp register field descriptions field description 7-0 ptp port p general-purpose input/output data ?ata register when not used with an alternative signal, the associated pin can be used as general-purpose i/o. in general-purpose output mode the port data register bit value is driven to the pin. if the associated data direction bit is set to 1, a read returns the value of the port data register bit, otherwise the buffered pin input state is read. address 0x0259 ( g1 , g2 ) access: user read only 1 1 read: anytime write:never 76543210 r ptip7 ptip6 ptip5 ptip4 ptip3 ptip2 ptip1 ptip0 w reset 00000000 address 0x0259 ( g3 ) access: user read only 1 76543210 r 0 0 ptip5 ptip4 ptip3 ptip2 ptip1 ptip0 w reset 00000000 figure 2-36. port p input register (ptip) table 2-62. ptip register field descriptions field description 7-0 ptip port p input data a read always returns the buffered input state of the associated pin. it can be used to detect overload or short circuit conditions on output pins.
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 230 freescale semiconductor 2.4.3.36 port p data direction register (ddrp) 2.4.3.37 port p pull device enable register (perp) address 0x025a ( g1 , g2 ) access: user read/write 1 1 read: anytime write: anytime 76543210 r ddrp7 ddrp6 ddrp5 ddrp4 ddrp3 ddrp2 ddrp1 ddrp0 w reset 00000000 address 0x025a ( g3 ) access: user read/write 1 76543210 r0 0 ddrp5 ddrp4 ddrp3 ddrp2 ddrp1 ddrp0 w reset 00000000 figure 2-37. port p data direction register (ddrp) table 2-63. ddrp register field descriptions field description 7-0 ddrp port p data direction this bit determines whether the associated pin is an input or output. 1 associated pin con?ured as output 0 associated pin con?ured as input address 0x025c ( g1 , g2 ) access: user read/write 1 1 read: anytime write: anytime 76543210 r perp7 perp6 perp5 perp4 perp3 perp2 perp1 perp0 w reset 00000000 address 0x025c ( g3 ) access: user read/write 1 76543210 r0 0 perp5 perp4 perp3 perp2 perp1 perp0 w reset 00000000 figure 2-38. port p pull device enable register (perp)
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 231 2.4.3.38 port p polarity select register (ppsp) table 2-64. perp register field descriptions field description 7-0 perp port p pull device enable ?nable pull device on input pin this bit controls whether a pull device on the associated port input pin is active. if a pin is used as output this bit has no effect. the polarity is selected by the related polarity select register bit. 1 pull device enabled 0 pull device disabled address 0x025d ( g1 , g2 ) access: user read/write 1 1 read: anytime write: anytime 76543210 r ppsp7 ppsp6 ppsp5 ppsp4 ppsp3 ppsp2 ppsp1 ppsp0 w reset 00000000 address 0x025d ( g3 ) access: user read/write 1 76543210 r0 0 ppsp5 ppsp4 ppsp3 ppsp2 ppsp1 ppsp0 w reset 00000000 figure 2-39. port p polarity select register (ppsp) table 2-65. ppsp register field descriptions field description 7-0 ppsp port p pull device select ?on?ure pull device and pin interrupt edge polarity on input pin this bit selects a pullup or a pulldown device if enabled on the associated port input pin. this bit also selects the polarity of the active pin interrupt edge. 1 pulldown device selected; rising edge selected 0 pullup device selected; falling edge selected
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 232 freescale semiconductor 2.4.3.39 port p interrupt enable register (piep) read: anytime 2.4.3.40 port p interrupt flag register (pifp) address 0x025e ( g1 , g2 ) access: user read/write 1 1 read: anytime write: anytime 76543210 r piep7 piep6 piep5 piep4 piep3 piep2 piep1 piep0 w reset 00000000 address 0x025e ( g3 ) access: user read/write 1 76543210 r0 0 piep5 piep4 piep3 piep2 piep1 piep0 w reset 00000000 figure 2-40. port p interrupt enable register (piep) table 2-66. piep register field descriptions field description 7-0 piep port p interrupt enable this bit enables or disables the edge sensitive pin interrupt on the associated pin. an interrupt can be generated if the pin is operating in input or output mode when in use with the general-purpose or related peripheral function. 1 interrupt is enabled 0 interrupt is disabled (interrupt ?g masked) address 0x025f ( g1 , g2 ) access: user read/write 1 76543210 r pifp7 pifp6 pifp5 pifp4 pifp3 pifp2 pifp1 pifp0 w reset 00000000 address 0x025f ( g3 ) access: user read/write 1 76543210 r0 0 pifp5 pifp4 pifp3 pifp2 pifp1 pifp0 w reset 00000000 figure 2-41. port p interrupt flag register (pifp)
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 233 1 read: anytime write: anytime, write 1 to clear table 2-67. pifp register field descriptions field description 7-0 pifp port p interrupt ?g this ?g asserts after a valid active edge was detected on the related pin (see section 2.5.4.2, ?in interrupts and wakeup ?. this can be a rising or a falling edge based on the state of the polarity select register. an interrupt will occur if the associated interrupt enable bit is set. writing a logic ??to the corresponding bit ?ld clears the ?g. 1 active edge on the associated bit has occurred 0 no active edge occurred
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 234 freescale semiconductor 2.4.3.41 reserved registers note addresses 0x0260-0x0261 are reserved for acmp registers in g2 and g3 only. refer to acmp section acmp control register (acmpc)?and acmp status register (acmps)? 2.4.3.42 port j data register (ptj) address 0x0268 ( g1 , g2 ) access: user read/write 1 1 read: anytime. the data source is depending on the data direction value. write: anytime 76543210 r ptj7 ptj6 ptj5 ptj4 ptj3 ptj2 ptj1 ptj0 w reset 00000000 address 0x0268 ( g3 ) access: user read/write 1 76543210 r0000 ptj3 ptj2 ptj1 ptj0 w reset 00000000 figure 2-42. port j data register (ptj) table 2-68. ptj register field descriptions field description 7-0 ptj port j general-purpose input/output data ?ata register when not used with an alternative signal, the associated pin can be used as general-purpose i/o. in general-purpose output mode the port data register bit value is driven to the pin. if the associated data direction bit is set to 1, a read returns the value of the port data register bit, otherwise the buffered pin input state is read.
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 235 2.4.3.43 port j input register (ptij) 2.4.3.44 port j data direction register (ddrj) address 0x0269 ( g1 , g2 ) access: user read only 1 1 read: anytime write:never 76543210 r ptij7 ptij6 ptij5 ptij4 ptij3 ptij2 ptij1 ptij0 w reset 00000000 address 0x0269 ( g3 ) access: user read only 1 76543210 r0000 ptij3 ptij2 ptij1 ptij0 w reset 00000000 figure 2-43. port j input register (ptij) table 2-69. ptij register field descriptions field description 7-0 ptij port j input data a read always returns the buffered input state of the associated pin. it can be used to detect overload or short circuit conditions on output pins. address 0x026a ( g1 , g2 ) access: user read/write 1 1 read: anytime write: anytime 76543210 r ddrj7 ddrj6 ddrj5 ddrj4 ddrj3 ddrj2 ddrj1 ddrj0 w reset 00000000 address 0x026a ( g3 ) access: user read/write 1 76543210 r0000 ddrj3 ddrj2 ddrj1 ddrj0 w reset 00000000 figure 2-44. port j data direction register (ddrj)
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 236 freescale semiconductor 2.4.3.45 port j pull device enable register (perj) table 2-70. ddrj register field descriptions field description 7-0 ddrj port j data direction this bit determines whether the associated pin is an input or output. 1 associated pin con?ured as output 0 associated pin con?ured as input address 0x026c ( g1 , g2 ) access: user read/write 1 1 read: anytime write: anytime 76543210 r perj7 perj6 perj5 perj4 perj3 perj2 perj1 perj0 w reset 11111111 address 0x026c ( g3 ) access: user read/write 1 76543210 r0000 perj3 perj2 perj1 perj0 w reset 00001111 figure 2-45. port j pull device enable register (perj) table 2-71. perj register field descriptions field description 7-0 perj port j pull device enable ?nable pull device on input pin this bit controls whether a pull device on the associated port input pin is active. if a pin is used as output this bit has no effect. the polarity is selected by the related polarity select register bit. 1 pull device enabled 0 pull device disabled
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 237 2.4.3.46 port j polarity select register (ppsj) 2.4.3.47 port j interrupt enable register (piej) read: anytime address 0x026d ( g1 , g2 ) access: user read/write 1 1 read: anytime write: anytime 76543210 r ppsj7 ppsj6 ppsj5 ppsj4 ppsj3 ppsj2 ppsj1 ppsj0 w reset 00000000 address 0x026d ( g3 ) access: user read/write 1 76543210 r0000 ppsj3 ppsj2 ppsj1 ppsj0 w reset 00000000 figure 2-46. port j polarity select register (ppsj) table 2-72. ppsj register field descriptions field description 7-0 ppsj port j pull device select ?on?ure pull device and pin interrupt edge polarity on input pin this bit selects a pullup or a pulldown device if enabled on the associated port input pin. this bit also selects the polarity of the active pin interrupt edge. 1 pulldown device selected; rising edge selected 0 pullup device selected; falling edge selected address 0x026e ( g1 , g2 ) access: user read/write 1 76543210 r piej7 piej6 piej5 piej4 piej3 piej2 piej1 piej0 w reset 00000000 address 0x026e ( g3 ) access: user read/write 1 76543210 r0000 piej3 piej2 piej1 piej0 w reset 00000000 figure 2-47. port j interrupt enable register (piej)
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 238 freescale semiconductor 2.4.3.48 port j interrupt flag register (pifj) 1 read: anytime write: anytime table 2-73. piej register field descriptions field description 7-0 piej port j interrupt enable this bit enables or disables the edge sensitive pin interrupt on the associated pin. an interrupt can be generated if the pin is operating in input or output mode when in use with the general-purpose or related peripheral function. 1 interrupt is enabled 0 interrupt is disabled (interrupt ?g masked) address 0x026f ( g1 , g2 ) access: user read/write 1 1 read: anytime write: anytime, write 1 to clear 76543210 r pifj7 pifj6 pifj5 pifj4 pifj3 pifj2 pifj1 pifj0 w reset 00000000 address 0x026f ( g3 ) access: user read/write 1 76543210 r0000 pifj3 pifj2 pifj1 pifj0 w reset 00000000 figure 2-48. port j interrupt flag register (pifj) table 2-74. pifj register field descriptions field description 7-0 pifj port j interrupt ?g this ?g asserts after a valid active edge was detected on the related pin (see section 2.5.4.2, ?in interrupts and wakeup ?. this can be a rising or a falling edge based on the state of the polarity select register. an interrupt will occur if the associated interrupt enable bit is set. writing a logic ??to the corresponding bit ?ld clears the ?g. 1 active edge on the associated bit has occurred 0 no active edge occurred
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 239 2.4.3.49 port ad data register (pt0ad) 2.4.3.50 port ad data register (pt1ad) address 0x0270 ( g1 , g2 ) access: user read/write 1 1 read: anytime. the data source is depending on the data direction value. write: anytime 76543210 r pt0ad7 pt0ad6 pt0ad5 pt0ad4 pt0ad3 pt0ad2 pt0ad1 pt0ad0 w reset 00000000 address 0x0270 ( g3 ) access: user read/write 1 76543210 r0000 pt0ad3 pt0ad2 pt0ad1 pt0ad0 w reset 00000000 figure 2-49. port ad data register (pt0ad) table 2-75. pt0ad register field descriptions field description 7-0 pt0ad port ad general-purpose input/output data ?ata register when not used with an alternative signal, the associated pin can be used as general-purpose i/o. in general-purpose output mode the port data register bit value is driven to the pin. if the associated data direction bit is set to 1, a read returns the value of the port data register bit, otherwise the buffered pin input state is read if the digital input buffers are enabled ( section 2.3.12, ?ins ad15-0 ?. address 0x0271 access: user read/write 1 1 read: anytime. the data source is depending on the data direction value. write: anytime 76543210 r pt1ad7 pt1ad6 pt1ad5 pt1ad4 pt1ad3 pt1ad2 pt1ad1 pt1ad0 w reset 00000000 figure 2-50. port ad data register (pt1ad)
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 240 freescale semiconductor 2.4.3.51 port ad input register (pti0ad) 2.4.3.52 port ad input register (pti1ad) table 2-76. pt1ad register field descriptions field description 7-0 pt1ad port ad general-purpose input/output data ?ata register when not used with an alternative signal, the associated pin can be used as general-purpose i/o. in general-purpose output mode the port data register bit value is driven to the pin. if the associated data direction bit is set to 1, a read returns the value of the port data register bit, otherwise the buffered pin input state is read if the digital input buffers are enabled ( section 2.3.12, ?ins ad15-0 ?. address 0x0272 ( g1 , g2 ) access: user read only 1 1 read: anytime write: never 76543210 r pti0ad7 pti0ad6 pti0ad5 pti0ad4 pti0ad3 pti0ad2 pti0ad1 pti0ad0 w reset 00000000 address 0x0272 ( g3 ) access: user read only 1 76543210 r0000 pti0ad3 pti0ad2 pti0ad1 pti0ad0 w reset 00000000 figure 2-51. port ad input register (pti0ad) table 2-77. pti0ad register field descriptions field description 7-0 pti0ad port ad input data a read always returns the buffered input state of the associated pin. it can be used to detect overload or short circuit conditions on output pins. address 0x0273 access: user read only 1 1 read: anytime write: never 76543210 r pti1ad7 pti1ad6 pti1ad5 pti1ad4 pti1ad3 pti1ad2 pti1ad1 pti1ad0 w reset 00000000 figure 2-52. port ad input register (pti1ad)
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 241 2.4.3.53 port ad data direction register (ddr0ad) 2.4.3.54 port ad data direction register (ddr1ad) table 2-78. pti1ad register field descriptions field description 7-0 pti1ad port ad input data a read always returns the buffered input state of the associated pin. it can be used to detect overload or short circuit conditions on output pins. address 0x0274 ( g1 , g2 ) access: user read/write 1 1 read: anytime write: anytime 76543210 r ddr0ad7 ddr0ad6 ddr0ad5 ddr0ad4 ddr0ad3 ddr0ad2 ddr0ad1 ddr0ad0 w reset 00000000 address 0x0274 ( g3 ) access: user read/write 1 76543210 r0000 ddr0ad3 ddr0ad2 ddr0ad1 ddr0ad0 w reset 00000000 figure 2-53. port ad data direction register (ddr0ad) table 2-79. ddr0ad register field descriptions field description 7-0 ddr0ad port ad data direction this bit determines whether the associated pin is an input or output. 1 associated pin con?ured as output 0 associated pin con?ured as input address 0x0275 access: user read/write 1 1 read: anytime write: anytime 76543210 r ddr1ad7 ddr1ad6 ddr1ad5 ddr1ad4 ddr1ad3 ddr1ad2 ddr1ad1 ddr1ad0 w reset 00000000 figure 2-54. port ad data direction register (ddr1ad)
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 242 freescale semiconductor 2.4.3.55 reserved register note address 0x0276 is reserved for rva on g(a)240 and g(a)192 only. refer to rva section ?va control register (rvactl)? 2.4.3.56 pin routing register 1 (prr1) note routing takes only effect if pkgcr is set to select the 100 lqfp package. table 2-80. ddr1ad register field descriptions field description 7-0 ddr1ad port ad data direction this bit determines whether the associated pin is an input or output. 1 associated pin con?ured as output 0 associated pin con?ured as input address 0x0277 (g(a)240 and g(a)192 only) access: user read/write 1 1 read: anytime write: anytime 76543210 r0000000 prr1an w reset 00000000 address 0x0277 (non g(a)240 and g(a)192) access: user read/write 76543210 r00000000 w reset 00000000 figure 2-55. pin routing register (prr1) table 2-81. prr1 register field descriptions field description 0 prr1an pin routing register adc channels ?select alternative routing for an15/14/13/11/10 pins to port c this bit programs the routing of the speci? adc channels to alternative external pins in 100 lqfp. see table 2-82 . the routing affects the analog signals and digital input trigger paths to the adc. refer to the related pin descriptions in section 2.3.4, ?ins pc7-0 ?and section 2.3.12, ?ins ad15-0 ? 1 an inputs on port c 0 an inputs on port ad
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 243 2.4.3.57 port ad pull enable register (per0ad) table 2-82. an routing options prr1an associated pins 0 an10 - pad10 an11 - pad11 an13 - pad13 an14 - pad14 an15 - pad15 1 an10 - pc0 an11 - pc1 an13 - pc2 an14 - pc3 an15 - pc4 address 0x0278 ( g1 , g2 ) access: user read/write 1 1 read: anytime write: anytime 76543210 r per0ad7 per0ad6 per0ad5 per0ad4 per0ad3 per0ad2 per0ad1 per0ad0 w reset 00000000 address 0x0278 ( g3 ) access: user read/write 1 76543210 r0000 per0ad3 per0ad2 per0ad1 per0ad0 w reset 00000000 figure 2-56. port ad pullup enable register (per0ad) table 2-83. per0ad register field descriptions field description 7-0 per0ad port ad pull enable ?nable pull device on input pin this bit controls whether a pull device on the associated port input pin is active. if a pin is used as output this bit has no effect. the polarity is selected by the related polarity select register bit. 1 pull device enabled 0 pull device disabled
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 244 freescale semiconductor 2.4.3.58 port ad pull enable register (per1ad) 2.4.3.59 port ad polarity select register (pps0ad) address 0x0279 access: user read/write 1 1 read: anytime write: anytime 76543210 r per1ad7 per1ad6 per1ad5 per1ad4 per1ad3 per1ad2 per1ad1 per1ad0 w reset 00000000 figure 2-57. port ad pullup enable register (per1ad) table 2-84. per1ad register field descriptions field description 7-0 per1ad port ad pull enable ?nable pull device on input pin this bit controls whether a pull device on the associated port input pin is active. if a pin is used as output this bit has no effect. the polarity is selected by the related polarity select register bit. 1 pull device enabled 0 pull device disabled address 0x027a ( g1 , g2 ) access: user read/write 1 1 read: anytime write: anytime 76543210 r pps0ad7 pps0ad6 pps0ad5 pps0ad4 pps0ad3 pps0ad2 pps0ad1 pps0ad0 w reset 00000000 address 0x027a ( g3 ) access: user read/write 1 76543210 r0000 pps0ad3 pps0ad2 pps0ad1 pps0ad0 w reset 00000000 figure 2-58. port ad polarity select register (pps0ad)
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 245 2.4.3.60 port ad polarity select register (pps1ad) table 2-85. pps0ad register field descriptions field description 7-0 pps0ad port ad pull device select ?on?ure pull device and pin interrupt edge polarity on input pin this bit selects a pullup or a pulldown device if enabled on the associated port input pin. this bit also selects the polarity of the active pin interrupt edge. 1 pulldown device selected; rising edge selected 0 pullup device selected; falling edge selected address 0x027b access: user read/write 1 1 read: anytime write: anytime 76543210 r pps1ad7 pps1ad6 pps1ad5 pps1ad4 pps1ad3 pps1ad2 pps1ad1 pps1ad0 w reset 00000000 figure 2-59. port ad polarity select register (pps1ad) table 2-86. pps1ad register field descriptions field description 7-0 pps1ad port ad pull device select ?on?ure pull device and pin interrupt edge polarity on input pin this bit selects a pullup or a pulldown device if enabled on the associated port input pin. this bit also selects the polarity of the active pin interrupt edge. 1 pulldown device selected; rising edge selected 0 pullup device selected; falling edge selected
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 246 freescale semiconductor 2.4.3.61 port ad interrupt enable register (pie0ad) read: anytime 2.4.3.62 port ad interrupt enable register (pie1ad) read: anytime address 0x027c ( g1 , g2 ) access: user read/write 1 1 read: anytime write: anytime 76543210 r pie0ad7 pie0ad6 pie0ad5 pie0ad4 pie0ad3 pie0ad2 pie0ad1 pie0ad0 w reset 00000000 address 0x027c ( g3 ) access: user read/write 1 76543210 r0000 pie0ad3 pie0ad2 pie0ad1 pie0ad0 w reset 00000000 figure 2-60. port ad interrupt enable register (pie0ad) table 2-87. pie0ad register field descriptions field description 7-0 pie0ad port ad interrupt enable this bit enables or disables the edge sensitive pin interrupt on the associated pin. an interrupt can be generated if the pin is operating in input or output mode when in use with the general-purpose or related peripheral function. 1 interrupt is enabled 0 interrupt is disabled (interrupt ?g masked) address 0x027d access: user read/write 1 1 read: anytime write: anytime 76543210 r pie1ad7 pie1ad6 pie1ad5 pie1ad4 pie1ad3 pie1ad2 pie1ad1 pie1ad0 w reset 00000000 figure 2-61. port ad interrupt enable register (pie1ad)
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 247 2.4.3.63 port ad interrupt flag register (pif0ad) table 2-88. pie1ad register field descriptions field description 7-0 pie1ad port ad interrupt enable this bit enables or disables the edge sensitive pin interrupt on the associated pin. an interrupt can be generated if the pin is operating in input or output mode when in use with the general-purpose or related peripheral function. 1 interrupt is enabled 0 interrupt is disabled (interrupt ?g masked) address 0x027e ( g1 , g2 ) access: user read/write 1 1 read: anytime write: anytime, write 1 to clear 76543210 r pif0ad7 pif0ad6 pif0ad5 pif0ad4 pif0ad3 pif0ad2 pif0ad1 pif0ad0 w reset 00000000 address 0x027e ( g3 ) access: user read/write 1 76543210 r0000 pif0ad3 pif0ad2 pif0ad1 pif0ad0 w reset 00000000 figure 2-62. port ad interrupt flag register (pif0ad) table 2-89. pif0ad register field descriptions field description 7-0 pif0ad port ad interrupt ?g this ?g asserts after a valid active edge was detected on the related pin (see section 2.5.4.2, ?in interrupts and wakeup ?. this can be a rising or a falling edge based on the state of the polarity select register. an interrupt will occur if the associated interrupt enable bit is set. writing a logic ??to the corresponding bit ?ld clears the ?g. 1 active edge on the associated bit has occurred 0 no active edge occurred
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 248 freescale semiconductor 2.4.3.64 port ad interrupt flag register (pif1ad) address 0x027f access: user read/write 1 1 read: anytime write: anytime 76543210 r pif1ad7 pif1ad6 pif1ad5 pif1ad4 pif1ad3 pif1ad2 pif1ad1 pif1ad0 w reset 00000000 figure 2-63. port ad interrupt flag register (pif1ad) table 2-90. pif1ad register field descriptions field description 7-0 pif1ad port ad interrupt ?g this ?g asserts after a valid active edge was detected on the related pin (see section 2.5.4.2, ?in interrupts and wakeup ?. this can be a rising or a falling edge based on the state of the polarity select register. an interrupt will occur if the associated interrupt enable bit is set. writing a logic ??to the corresponding bit ?ld clears the ?g. 1 active edge on the associated bit has occurred 0 no active edge occurred
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 249 2.5 pim ports - functional description 2.5.1 general each pin except bkgd can act as general-purpose i/o. in addition most pins can act as an output or input of a peripheral module. 2.5.2 registers a set of con?uration registers is common to all ports with exception of the adc port ( table 2-91 ). all registers can be written at any time, however a speci? con?uration might not become active. example: selecting a pullup device. this device does not become active while the port is used as a push-pull output. 2.5.2.1 data register (portx, ptx) this register holds the value driven out to the pin if the pin is used as a general-purpose i/o. writing to this register has only an effect on the pin if the pin is used as general-purpose output. when reading this address, the buffered state of the pin is returned if the associated data direction register bit is set to 0. if the data direction register bits are set to 1, the contents of the data register is returned. this is independent of any other con?uration ( figure 2-64 ). 2.5.2.2 input register (ptix) this register is read-only and always returns the buffered state of the pin ( figure 2-64 ). table 2-91. register availability per port 1 1 each cell represents one register with individual con?uration bits port data (portx, ptx) input (ptix) data direction (ddrx) pull enable (perx) polarity select (ppsx) wired- or mode (womx) interrupt enable (piex) interrupt flag (pifx) a yes - yes yes ---- byes-yes ---- cyes-yes ---- dyes-yes ---- eyes-yes ---- t yes yes yes yes yes - - - s yes yes yes yes yes yes - - m yes yes yes yes yes yes - - p yes yes yes yes yes - yes yes j yes yes yes yes yes - yes yes ad yes yes yes yes yes - yes yes
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 250 freescale semiconductor 2.5.2.3 data direction register (ddrx) this register de?es whether the pin is used as an general-purpose input or an output. if a peripheral module controls the pin the contents of the data direction register is ignored ( figure 2-64 ). independent of the pin usage with a peripheral module this register determines the source of data when reading the associated data register address ( 2.5.2.1/2-249 ). note due to internal synchronization circuits, it can take up to 2 bus clock cycles until the correct value is read on port data or port input registers, when changing the data direction register. figure 2-64. illustration of i/o pin functionality 2.5.2.4 pull device enable register (perx) this register turns on a pullup or pulldown device on the related pins determined by the associated polarity select register ( 2.5.2.5/2-250 ). the pull device becomes active only if the pin is used as an input or as a wired-or output. some peripheral module only allow certain con?urations of pull devices to become active. refer to section 2.3, ?im routing - functional description ? 2.5.2.5 pin polarity select register (ppsx) this register selects either a pullup or pulldown device if enabled. it becomes only active if the pin is used as an input. a pullup device can be activated if the pin is used as a wired-or output. pt ddr output enable module enable 1 0 1 1 0 0 pin pti data out module
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 251 2.5.2.6 wired-or mode register (womx) if the pin is used as an output this register turns off the active-high drive. this allows wired-or type connections of outputs. 2.5.2.7 interrupt enable register (piex) if the pin is used as an interrupt input this register serves as a mask to the interrupt ?g to enable/disable the interrupt. 2.5.2.8 interrupt flag register (pifx) if the pin is used as an interrupt input this register holds the interrupt ?g after a valid pin event. 2.5.2.9 pin routing register (prrx) this register allows software re-con?uration of the pinouts for speci? peripherals in the 20 tssop package only. 2.5.2.10 package code register (pkgcr) this register determines the package in use. pre programmed by factory. 2.5.3 pin con?uration summary the following table summarizes the effect of the various con?uration bits, that is data direction (ddr), output level (io), pull enable (pe), pull select (ps) on the pin function and pull device 1 . the con?uration bit ps is used for two purposes: 1. con?ure the sensitive interrupt edge (rising or falling), if interrupt is enabled. 2. select either a pullup or pulldown device if pe is active. 1.
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 252 freescale semiconductor table 2-92. pin con?uration summary 2.5.4 interrupts this section describes the interrupts generated by the pim and their individual sources. vector addresses and interrupt priorities are de?ed at mcu level. 2.5.4.1 xirq, irq interrupts the xirq pin allows requesting non-maskable interrupts after reset initialization. during reset, the x bit in the condition code register is set and any interrupts are masked until software enables them. the irq pin allows requesting asynchronous interrupts. the interrupt input is disabled out of reset. to enable the interrupt the irqcr[irqen] bit must be set and the i bit cleared in the condition code register. the interrupt can be con?ured for level-sensitive or falling-edge-sensitive triggering. if irqcr[irqen] is cleared while an interrupt is pending, the request will deassert. ddr io pe ps 1 1 always ??on port a, b, c, d, bkgd. always ??on port e ie 2 2 applicable only on port p, j and ad. function pull device interrupt 0 x 0 x 0 input 3 3 port ad: assuming digital input buffer enabled in adc module (atddien) and acmp module (acdien) disabled disabled 0 x 1 0 0 input 3 pullup disabled 0 x 1 1 0 input 3 pulldown disabled 0 x 0 0 1 input 3 disabled falling edge 0 x 0 1 1 input 3 disabled rising edge 0 x 1 0 1 input 3 pullup falling edge 0 x 1 1 1 input 3 pulldown rising edge 1 0 x x 0 output, drive to 0 disabled disabled 1 1 x x 0 output, drive to 1 disabled disabled 1 0 x 0 1 output, drive to 0 disabled falling edge 1 1 x 1 1 output, drive to 1 disabled rising edge table 2-93. pim interrupt sources module interrupt sources local enable xirq none irq irqcr[irqen] port p pin interrupt piep[piep7-piep0] port j pin interrupt piej[piej7-piej0] port ad pin interrupt pie0ad[pie0ad7-pie0ad0] pie1ad[pie1ad7-pie1ad0]
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 253 both interrupts are capable to wake-up the device from stop mode. means for glitch ?tering are not provided on these pins. 2.5.4.2 pin interrupts and wakeup ports p, j and ad offer pin interrupt capability. the related interrupt enable (pie) as well as the sensitivity to rising or falling edges (pps) can be individually con?ured on per-pin basis. all bits/pins in a port share the same interrupt vector. interrupts can be used with the pins con?ured as inputs or outputs. an interrupt is generated when a port interrupt ?g (pif) and its corresponding port interrupt enable (pie) are both set. the pin interrupt feature is also capable to wake up the cpu when it is in stop or wait mode. a digital ?ter on each pin prevents short pulses from generating an interrupt. a valid edge on an input is detected if 4 consecutive samples of a passive level are followed by 4 consecutive samples of an active level. else the sampling logic is restarted. in run and wait mode the ?ters are continuously clocked by the bus clock. pulses with a duration of t pulse n p_pass /f bus guarantee a pin interrupt. in stop mode the clock is generated by an rc-oscillator. the minimum pulse length varies over process conditions, temperature and voltage ( figure 2-65 ). pulses with a duration of t pulse < t p_mask are assuredly ?tered out while pulses with a duration of t pulse > t p_pass guarantee a wakeup event. please refer to the appendix table ?in interrupt characteristics?for pulse length limits. to maximize current saving the rc oscillator is active only if the following condition is true on any individual pin: sample count <= 4 (at active or passive level) and interrupt enabled (pie=1) and interrupt ?g not set (pif=0). figure 2-65. interrupt glitch filter (here: active low level selected) glitch, ?tered out, no interrupt ?g set valid pulse, interrupt ?g set uncertain t pulse (min) t pulse (max)
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 254 freescale semiconductor 2.6 initialization/application information 2.6.1 initialization after a system reset, software should: 1. read the pkgcr and write to it with its preset content to engage the write lock on pkgcr[pkgcr2:pkgcr0] bits protecting the device from inadvertent changes to the pin layout in normal applications. 2. write to prr0 in 20 tssop to de?e the module routing and to pkgcr[apiclks7] bit in any package for api_extclk. ga240 / ga192 devices only: 3. in applications using the analog functions on port c pins shared with ampm1, ampp1 or dacu1 the input buffers should be disabled early after reset by enabling the related mode of the dac1 module. this shortens the time of potentially increased power consumption caused by the digital input buffers operating in the linear region. 2.6.2 port data and data direction register writes it is not recommended to write portx/ptx and ddrx in a word access. when changing the register pins from inputs to outputs, the data may have extra transitions during the write access. initialize the port data register before enabling the outputs. 2.6.3 enabling irq edge-sensitive mode to avoid unintended irq interrupts resulting from writing to irqcr while the irq pin is driven to active level ( irq=0) the following initialization sequence is recommended: 1. mask i-bit 2. set irqcr[irqen] 3. set irqcr[irqe] 4. clear i-bit 2.6.4 adc external triggers etrig3-0 the adc external trigger inputs etrig3-0 allow the synchronization of conversions to external trigger events if selected as trigger source (for details refer to atdctl1[etrigsel] and atdctl1[etrigch] con?uration bits in adc section). these signals are related to pwm channels 3-0 to support periodic trigger applications with the adc. other pin functions can also be used as triggers. if a pwm channel is routed to an alternative pin, the etrig input function will follow the relocation accordingly. if the related pwm channel is enabled, the pwm signal as seen on the pin will drive the etrig input. if another signal of higher priority takes control of the pin or if on a port ad pin the input buffer is disabled,
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 255 the etrig will be driven by the pwm internally. if the related pwm channel is not enabled, the etrig function will be triggered by other functions on the pin including general-purpose input. table 2-94 illustrates the resulting trigger sources and their dependencies. shaded ?lds apply to 20 tssop with shared acmp analog input functions on port ad pins only. 2.6.5 emulation of smaller packages the package code register (pkgcr) allows the emulation of smaller packages to support software development and debugging without need to have the actual target package at hand. cross-device programming for the shared functions is also supported because smaller package sizes than the given device is offered in can be selected 1 . the pkgcr can be written in normal mode once after reset to overwrite the factory pre-programmed value, which determines the actual package. further attempts are blocked to avoid inadvertent changes (blocking released in special mode). trying to select a package larger than the given device is offered in will be ignored and result in the ?llegal?code being written. when a smaller package is selected the pin availability and pin functionality changes according to the target package speci?ation. the input buffers of unused pins are disabled however the output functions of unused pins are not disabled. therefore these pins should be dont-cared. depending on the different feature sets of the g-family derivatives the input buffers of speci? pins, which are shared with analog functions need to be explicitly enabled before they can be used with digital input functions. for example devices featuring an acmp module contain a control register for the related input buffers, which is not available on other family members. also larger devices in general feature more adc channels with individual input buffer enable bits, which are not present on smaller ones. these differences need to be accounted for when developing cross-functional code. table 2-94. etrig sources port ad input buffer enable 1 1 refer to note/2-180 for enable condition pwm enable peripheral enable 2 2 with higher priority than pwm on pin including acmp enable (acmpc[ace]=1) etrig source comment 0 0 0 const. 1 forced high 0 0 1 const. 1 forced high 0 1 0 pwm internal link 0 1 1 pwm internal link 1 0 0 pin driven by general-purpose function 1 0 1 pin driven by peripheral 1 1 0 pin driven by pwm 1 1 1 pwm internal link 1. except g(a)128/g(a)96 in 20 tssop: internal routing of pwm to etrig is not available.
port integration module (s12gpimv1) mc9s12g family reference manual, rev.1.23 256 freescale semiconductor
mc9s12g family reference manual, rev.1.23 freescale semiconductor 257 chapter 3 5v analog comparator (acmpv1) revision history 3.1 introduction the analog comparator (acmp) provides a circuit for comparing two analog input voltages. refer to the device overview section for availability on a speci? device. 3.2 features the acmp has the following features: low offset, low long-term offset drift selectable interrupt on rising, falling, or rising and falling edges of comparator output option to output comparator signal on an external pin acmpo option to trigger timer input capture events 3.3 block diagram the block diagram of the acmp is shown below. rev. no. (item no.) date (submitted by) sections affected substantial change(s) v00.08 13 aug 2010 added register name to every bit?ld reference v00.09 10 sep 2010 internal updates v01.00 18 oct 2010 initial version
5v analog comparator (acmpv1) mc9s12g family reference manual, rev.1.23 258 freescale semiconductor figure 3-1. acmp block diagram figure 3-2. 3.4 external signals the acmp has two analog input signals, acmpp and acmpm, and one digital output, acmpo. the associated pins are defined by the package option. the acmpp signal is connected to the non-inverting input of the comparator. the acmpm signal is connected to the inverting input of the comparator. each of these signals can accept an input voltage that varies across the full 5v operating voltage range. the module monitors the voltage on these inputs independent of any other functions in use (gpio, adc). the raw comparator output signal can optionally be driven on an external pin. 3.5 modes of operation 1. normal mode the acmp is operating when enabled and not in stop mode. 2. shutdown mode the acmp is held in shutdown mode either when disabled or during stop mode. in this case the supply of the analog block is disconnected for power saving. acmpo drives zero in shutdown mode. interrupt control acmp irq control & status register acmod set acif ace acif acie acope acmpo aco acmpp acmpm to input + _ (enable) acice capture sync hold channel acdien digital buffer input internal bus
5v analog comparator (acmpv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 259 3.6 memory map and register de?ition 3.6.1 register map table 3-1 shows the acmp register map. table 3-1. acmp register map 3.6.2 register descriptions 3.6.2.1 acmp control register (acmpc) global address register name bit 7 654321 bit 0 0x0260 acmpc r acie acope acice acdien acmod1 acmod0 0 ace w 0x0261 acmps r acif aco000000 w = unimplemented or reserved address 0x0260 access: user read/write 1 1 read: anytime write: anytime 76543210 r acie acope acice acdien acmod1 acmod0 0 ace w reset 00000000 figure 3-3. acmp control register (acmpc) table 3-2. acmpc register field descriptions field description 7 acie acmp interrupt enable enables the acmp interrupt. 0 interrupt disabled 1 interrupt enabled 6 acope acmp output pin enable enables raw comparator output on external acmpo pin. 0 acmp output not available 1 acmp output is driven out on acmpo
5v analog comparator (acmpv1) mc9s12g family reference manual, rev.1.23 260 freescale semiconductor 3.6.2.2 acmp status register (acmps) 5 acice acmp input capture enable establishes internal link to a timer input capture channel. when enabled, the associated timer pin is disconnected from the timer input. refer to ace description to account for initialization delay on this path. 0 timer link disabled 1 acmp output connected to input capture channel 5 4 acdien acmp digital input buffer enable enables the input buffers on acmpp and acmpm for the pins to be used with digital functions. note: if this bit is set while simultaneously using the pin as an analog port, there is potentially increased power consumption because the digital input buffer may be in the linear region. 0 input buffers disabled on acmpp and acmpm 1 input buffers enabled on acmpp and acmpm 3-2 acmod [1:0] acmp mode selects the type of compare event setting acif. 00 flag setting disabled 01 comparator output rising edge 10 comparator output falling edge 11 comparator output rising or falling edge 0 ace acmp enable this bit enables the acmp module and takes it into normal mode (see section 3.5, ?odes of operation ?. this bit also connects the related input pins with the modules low pass input ?ters. when the module is not enabled, it remains in low power shutdown mode. note: after setting ace=1 an initialization delay of 63 bus clock cycles must be accounted for. during this time the comparator output path to all subsequent logic (aco, acif, timer link, excl. acmpo) is held at its current state. when resetting ace to 0 the current state of the comparator will be maintained. 0 acmp disabled 1 acmp enabled address 0x0261 access: user read/write 1 1 read: anytime write: acif: anytime, write 1 to clear aco: never 76543210 r acif aco000000 w reset 00000000 figure 3-4. acmp status register (acmps) table 3-2. acmpc register field descriptions (continued) field description
5v analog comparator (acmpv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 261 3.7 functional description the acmp compares two analog input voltages applied to acmpm and acmpp. the comparator output is high when the voltage at the non-inverting input is greater than the voltage at the inverting input, and is low when the non-inverting input voltage is lower than the inverting input voltage. the acmp is enabled with register bit acmpc[ace]. when acmpc[ace] is set, the input pins are connected to low-pass filters. the comparator output is disconnected from the subsequent logic, which is held at its state for 63 bus clock cycles after setting acmpc[ace] to ? to mask potential glitches. this initialization delay must be accounted for before the first comparison result can be expected. the initial hold state after reset is zero, thus if input voltages are set to result in ?rue?result (v acmpp >v acmpm ) before the initialization delay has passed, a flag will be set immediately after this. similarly the flag will also be set when disabling the acmp, then re-enabling it with the inputs changing to produce an opposite result to the hold state before the end of the initialization delay. by setting the acmpc[acice] bit the gated comparator output can be connected to the synchronized timer input capture channel 5 (see figure 3-1 ). this feature can be used to generate time stamps and timer interrupts on acmp events. the comparator output signal synchronized to the bus clock is used to read the comparator output status (acmps[aco]) and to set the interrupt flag (acmps[acif]). the condition causing the interrupt flag (acmps[acif]) to assert is selected with register bits acmpc[acmod1:acmod0]. this includes any edge configuration, that is rising, or falling, or rising and falling (toggle) edges of the comparator output. also flag setting can be disabled. an interrupt will be generated if the interrupt enable bit (acmpc[acie]) and the interrupt flag (acmps[acif]) are both set. acmps[acif] is cleared by writing a 1. the raw comparator output signal acmpo can be driven out on an external pin by setting the acmpc[acope] bit. table 3-3. acmps register field descriptions field description 7 acif acmp interrupt flag acif is set when a compare event occurs. compare events are de?ed by acmod[1:0]. writing a logic ??to the bit ?ld clears the ?g. 0 compare event has not occurred 1 compare event has occurred 6 aco acmp output reading aco returns the current value of the synchronized acmp output. refer to ace description to account for initialization delay on this path.
5v analog comparator (acmpv1) mc9s12g family reference manual, rev.1.23 262 freescale semiconductor
mc9s12g family reference manual, rev.1.23 freescale semiconductor 263 chapter 4 reference voltage attenuator (rvav1) revision history 4.1 introduction the reference voltage attenuator (rva) provides a circuit for reduction of the adc reference voltage difference vrh-vssa to gain more adc resolution. 4.2 features the rva has the following features: attenuation of adc reference voltage with low long-term drift 4.3 block diagram the block diagram of the rva module is shown below. refer to device overview section ?dc vrh/vrl signal connection?for connection of rva to pins and adc module. rev. no. (item no.) date (submitted by) sections affected substantial change(s) v00.05 09 jun 2010 added appendix title in note to reference reduced adc clock orthographical corrections aligned to freescale publications style guide v00.06 01 jul 2010 aligned to s12 register guidelines v01.00 18 oct 2010 initial version
reference voltage attenuator (rvav1) mc9s12g family reference manual, rev.1.23 264 freescale semiconductor figure 4-1. rva module block diagram 4.4 external signals the rva has two external input signals, vrh and vssa. 4.5 modes of operation 1. attenuation mode the rva is attenuating the reference voltage when enabled by the register control bit and the mcu not being in stop mode. 2. bypass mode the rva is in bypass mode either when disabled or during stop mode. in these cases the resistor ladder of the rva is disconnected for power saving. vrh_int vrl_int to adc rva rvaon vssa vrh 5r 4r r stop
reference voltage attenuator (rvav1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 265 4.6 memory map and register de?ition 4.6.1 register map table 4-1 shows the rva register map. table 4-1. rva register map 4.6.2 register descriptions 4.6.2.1 rva control register (rvactl) global address register name bit 7 654321 bit 0 0x0276 rvactl r0000000 rvaon w = unimplemented or reserved address 0x0276 access: user read/write 1 1 read: anytime write: anytime 76543210 r0000000 rvaon w reset 00000000 figure 4-2. rva control register (rvactl) table 4-2. rvactl register field descriptions field description 0 rvaon rva on this bit turns on the reference voltage attenuation. 0 rva in bypass mode 1 rva in attenuation mode
reference voltage attenuator (rvav1) mc9s12g family reference manual, rev.1.23 266 freescale semiconductor 4.7 functional description the rva is a prescaler for the adc reference voltage. if the attenuation is turned off the resistive divider is disconnected from vssa, vrh_int is connected to vrh and vrl_int is connected to vssa. in this mode the attenuation is bypassed and the resistive divider does not draw current. if the attenuation is turned on the resistive divider is connected to vssa, vrh_int and vrl_int are connected to intermediate voltage levels: vrh_int = 0.9 * (vrh - vssa) + vssa eqn. 4-1 vrl_int = 0.4 * (vrh - vssa) + vssa eqn. 4-2 the attenuated reference voltage difference (vrh_int - vrl_int) equals 50% of the input reference voltage difference (vrh - vssa). with reference voltage attenuation the resolution of the adc is improved by a factor of 2. note in attenuation mode the maximum adc clock is reduced. please refer to the conditions in appendix a atd accuracy? table atd conversion performance 5v range, rva enabled?
mc9s12g family reference manual, rev.1.23 freescale semiconductor 267 chapter 5 s12g memory map controller (s12gmmcv1) table 5-1. revision history table 5.1 introduction the s12gmmc module controls the access to all internal memories and peripherals for the cpu12 and s12sbdm module. it regulates access priorities and determines the address mapping of the on-chip resources. figure 5-1 shows a block diagram of the s12gmmc module. 5.1.1 glossary 5.1.2 overview the s12gmmc connects the cpu12s and the s12sbdms bus interfaces to the mcus on-chip resources (memories and peripherals). it arbitrates the bus accesses and determines all of the mcus memory maps. furthermore, the s12gmmc is responsible for constraining memory accesses on secured devices and for selecting the mcus functional mode. rev. no. (item no.) date (submitted by) sections affected substantial change(s) 01.02 20-may 2010 updates for s12vr48 and s12vr64 table 5-2. glossary of terms term de?ition local addresses address within the cpu12s local address map ( figure 5-11 ) global address address within the global address map ( figure 5-11 ) aligned bus access bus access to an even address. misaligned bus access bus access to an odd address. ns normal single-chip mode ss special single-chip mode unimplemented address ranges address ranges which are not mapped to any on-chip resource. nvm non-volatile memory; flash or eeprom ifr nvm information row. refer to ftmrg block guide
s12g memory map controller (s12gmmcv1) mc9s12g family reference manual, rev.1.23 268 freescale semiconductor 5.1.3 features the main features of this block are: paging capability to support a global 256 kbyte memory address space bus arbitration between the masters cpu12, s12sbdm to different resources. mcu operation mode control mcu security control generation of system reset when cpu12 accesses an unimplemented address (i.e., an address which does not belong to any of the on-chip modules) in single-chip modes 5.1.4 modes of operation the s12gmmc selects the mcus functional mode. it also determines the devices behavior in secured and unsecured state. 5.1.4.1 functional modes two functional modes are implemented on devices of the s12g product family: normal single chip (ns) the mode used for running applications. special single chip mode (ss) a debug mode which causes the device to enter bdm active mode after each reset. peripherals may also provide special debug features in this mode. 5.1.4.2 security s12g devices can be secured to prohibit external access to the on-chip ?sh. the s12gmmc module determines the access permissions to the on-chip memories in secured and unsecured state. 5.1.5 block diagram figure 5-1 shows a block diagram of the s12gmmc.
s12g memory map controller (s12gmmcv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 269 figure 5-1. s12gmmc block diagram 5.2 external signal description the s12gmmc uses two external pins to determine the devices operating mode: reset and modc ( figure 5-3 ) see device user guide (dug) for the mapping of these signals to device pins. 5.3 memory map and registers 5.3.1 module memory map a summary of the registers associated with the s12gmmc block is shown in figure 5-2 . detailed descriptions of the registers and bits are given in the subsections that follow. table 5-3. external system pins associated with s12gmmc pin name pin functions description reset (see section device overview) reset the reset pin is used the select the mcus operating mode. modc (see section device overview) modc the modc pin is captured at the rising edge of the reset pin. the captured value determines the mcus operating mode. cpu bdm target bus controller dbg mmc address decoder & priority peripherals flash eeprom ram
s12g memory map controller (s12gmmcv1) mc9s12g family reference manual, rev.1.23 270 freescale semiconductor 5.3.2 register descriptions this section consists of the s12gmmc control register descriptions in address order. 5.3.2.1 mode register (mode) address register name bit 7 65432 1 bit 0 0x000a reserved r 000000 0 0 w 0x000b mode r modc 00000 0 0 w 0x0010 reserved r 000000 0 0 w 0x0011 direct r dp15 dp14 dp13 dp12 dp11 dp10 dp9 dp8 w 0x0012 reserved r 000000 0 0 w 0x0013 mmcctl1 r 000000 0 nvmres w 0x0014 reserved r 000000 0 0 w 0x0015 ppage r 0000 pix3 pix2 pix1 pix0 w 0x0016- 0x0017 reserved r 000000 0 0 w = unimplemented or reserved figure 5-2. mmc register summary address: 0x000b 76543210 r modc 0000000 w reset modc 1 0000000 1. external signal (see table 5-3 ). = unimplemented or reserved figure 5-3. mode register (mode)
s12g memory map controller (s12gmmcv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 271 read: anytime. write: only if a transition is allowed (see figure 5-4 ). the modc bit of the mode register is used to select the mcus operating mode. figure 5-4. mode transition diagram when mcu is unsecured 5.3.2.2 direct page register (direct) read: anytime write: anytime in special ss, write-once in ns. this register determines the position of the 256 byte direct page within the memory map.it is valid for both global and local mapping scheme. table 5-4. mode field descriptions field description 7 modc mode select bit ?this bit controls the current operating mode during reset high (inactive). the external mode pin modc determines the operating mode during reset low (active). the state of the pin is registered into the respective register bit after the reset signal goes inactive (see figure 5-4 ). write restrictions exist to disallow transitions between certain modes. figure 5-4 illustrates all allowed mode changes. attempting non authorized transitions will not change the mode bit, but it will block further writes to the register bit except in special modes. write accesses to the mode register are blocked when the device is secured. address: 0x0011 76543210 r dp15 dp14 dp13 dp12 dp11 dp10 dp9 dp8 w reset 00000000 figure 5-5. direct register (direct) normal single-chip 1 special single-chip 0 (ss) reset (ns) 1 0 1
s12g memory map controller (s12gmmcv1) mc9s12g family reference manual, rev.1.23 272 freescale semiconductor figure 5-6. direct address mapping example 5-1. this example demonstrates usage of the direct addressing mode movb #$04,direct ;set direct register to 0x04. from this point on, all memory ;accesses using direct addressing mode will be in the local ;address range from 0x0400 to 0x04ff. ldy <$12 ;load the y index register from 0x0412 (direct access). 5.3.2.3 mmc control register (mmcctl1) read: anytime. write: anytime. the nvmres bit maps 16k of internal nvm resources (see section ftmrg) to the global address space 0x04000 to 0x07fff. table 5-5. direct field descriptions field description 7? dp[15:8] direct page index bits 15? ?these bits are used by the cpu when performing accesses using the direct addressing mode. these register bits form bits [15:8] of the local address (see figure 5-6 ). address: 0x0013 76543210 r0000000 nvmres w reset 00000000 = unimplemented or reserved figure 5-7. mmc control register (mmcctl1) table 5-6. mode field descriptions field description 0 nvmres map internal nvm resources into the global memory map write: anytime this bit maps internal nvm resources into the global address space. 0 program ?sh is mapped to the global address range from 0x04000 to 0x07fff. 1 nvm resources are mapped to the global address range from 0x04000 to 0x07fff. bit15 bit0 bit7 cpu address [15:0] bit8 dp [15:8]
s12g memory map controller (s12gmmcv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 273 5.3.2.4 program page index register (ppage) read: anytime write: anytime the four index bits of the ppage register select a 16k page in the global memory map ( figure 5-11 ). the selected 16k page is mapped into the paging window ranging from local address 0x8000 to 0xbfff. figure 5-9 illustrates the translation from local to global addresses for accesses to the paging window. the cpu has special access to read and write this register directly during execution of call and rtc instructions. figure 5-9. ppage address mapping note writes to this register using the special access of the call and rtc instructions will be complete before the end of the instruction execution. the ?ed 16kb page from 0x0000 to 0x3fff is the page number 0xc. parts of this page are covered by registers, eeprom and ram space. see soc guide for details. the ?ed 16kb page from 0x4000?x7fff is the page number 0xd. address: 0x0015 76543210 r0000 pix3 pix2 pix1 pix0 w reset 00001110 figure 5-8. program page index register (ppage) table 5-7. ppage field descriptions field description 3? pix[3:0] program page index bits 3? these page index bits are used to select which of the 256 ?sh array pages is to be accessed in the program page window. bit14 bit0 address [13:0] ppage register [3:0] global address [17:0] bit13 bit17 address: cpu local address or bdm local address
s12g memory map controller (s12gmmcv1) mc9s12g family reference manual, rev.1.23 274 freescale semiconductor the reset value of 0xe ensures that there is linear flash space available between addresses 0x0000 and 0xffff out of reset. the ?ed 16kb page from 0xc000-0xffff is the page number 0xf. 5.4 functional description the s12gmmc block performs several basic functions of the s12g sub-system operation: mcu operation modes, priority control, address mapping, select signal generation and access limitations for the system. each aspect is described in the following subsections. 5.4.1 mcu operating modes normal single chip mode this is the operation mode for running application code. there is no external bus in this mode. special single chip mode this mode is generally used for debugging operation, boot-strapping or security related operations. the active background debug mode is in control of the cpu code execution and the bdm ?mware is waiting for serial commands sent through the bkgd pin. 5.4.2 memory map scheme 5.4.2.1 cpu and bdm memory map scheme the bdm ?mware lookup tables and bdm register memory locations share addresses with other modules; however they are not visible in the memory map during users code execution. the bdm memory resources are enabled only during the read_bd and write_bd access cycles to distinguish between accesses to the bdm memory area and accesses to the other modules. (refer to bdm block guide for further details). when the mcu enters active bdm mode, the bdm ?mware lookup tables and the bdm registers become visible in the local memory map in the range 0xff00-0xffff (global address 0x3_ff00 - 0x3_ffff) and the cpu begins execution of ?mware commands or the bdm begins execution of hardware commands. the resources which share memory space with the bdm module will not be visible in the memory map during active bdm mode. please note that after the mcu enters active bdm mode the bdm ?mware lookup tables and the bdm registers will also be visible between addresses 0xbf00 and 0xbfff if the ppage register contains value of 0x0f. 5.4.2.1.1 expansion of the local address map expansion of the cpu local address map the program page index register in s12gmmc allows accessing up to 256kb of address space in the global memory map by using the four index bits (ppage[3:0]) to page 16x16 kb blocks into the program page window located from address 0x8000 to address 0xbfff in the local cpu memory map.
s12g memory map controller (s12gmmcv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 275 the page value for the program page window is stored in the ppage register. the value of the ppage register can be read or written by normal memory accesses as well as by the call and rtc instructions. control registers, vector space and parts of the on-chip memories are located in unpaged portions of the 64kb local cpu address space. the starting address of an interrupt service routine must be located in unpaged memory unless the user is certain that the ppage register will be set to the appropriate value when the service routine is called. however an interrupt service routine can call other routines that are in paged memory. the upper 16kb block of the local cpu memory space (0xc000?xffff) is unpaged. it is recommended that all reset and interrupt vectors point to locations in this area or to the other unmapped pages sections of the local cpu memory map. expansion of the bdm local address map ppage and bdmppr register is also used for the expansion of the bdm local address to the global address. these registers can be read and written by the bdm. the bdm expansion scheme is the same as the cpu expansion scheme. the four bdmppr program page index bits allow access to the full 256kb address map that can be accessed with 18 address bits. the bdm program page index register (bdmppr) is used only when the feature is enabled in bdm and, in the case the cpu is executing a ?mware command which uses cpu instructions, or by a bdm hardware commands. see the bdm block guide for further details. (see figure 5-10 ).
s12g memory map controller (s12gmmcv1) mc9s12g family reference manual, rev.1.23 276 freescale semiconductor figure 5-10. bdm hardware command bdm firmware command bit14 bit0 bdm local address [13:0] bdmppr register [3:0] global address [17:0] bit13 bit17 bit14 bit0 cpu local address [13:0] bdmppr register [3:0] global address [17:0] bit13 bit17
s12g memory map controller (s12gmmcv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 277 figure 5-11. local to global address mapping paging window 0x3_ffff local cpu and bdm memory map global memory map 0xffff 0xc000 0x0_0400 0x0_0000 0x3_c000 0x0000 0x8000 0x0400 0x4000 0x0_4000 paging window flash space flash space ram ram unimplemented unimplemented flash space flash space flash space flash space flash space flash space register space register space internal nvm resources internal nvm resources flash space flash space flash space flash space flash space flash space flash space flash space eeprom eeprom eeprom eeprom page 0x1 page 0x1 page 0xf page 0xf page 0xd page 0xd register space register space page 0xc page 0xc page 0xe page 0xe page 0xf page 0xf page 0xd page 0xd page 0xc page 0xc nvmres=0 nvmres=0 nvmres=1 nvmres=1 flash space flash space page 0x2 page 0x2 0x3_0000 0x3_4000 0x3_8000 0x0_8000 ram ram
s12g memory map controller (s12gmmcv1) mc9s12g family reference manual, rev.1.23 278 freescale semiconductor 5.4.3 unimplemented and reserved address ranges the s12gmmc is capable of mapping up 240k of ?sh, up to 4k of eeprom and up to 11k of ram into the global memory map. smaller devices of the s12g-family do not utilize all of the available address space. address ranges which are not associated with one of the on-chip memories fall into two categories: unimplemented addresses and reserved addresses. unimplemented addresses are not mapped to any of the on-chip memories. the s12gmmc is aware that accesses to these address location have no destination and triggers a system reset (illegal address reset) whenever they are attempted by the cpu. the bdm is not able to trigger illegal address resets. reserved addresses are associated with a memory block on the device, even though the memory block does not contain the resources to ?l the address space. the s12gmmc is not aware that the associated memory does not physically exist. it does not trigger an illegal address reset when accesses to reserved locations are attempted. table 5-8 shows the global address ranges of all members of the s12g-family. table 5-8. global address ranges s12gn16 s12gn32 s12g48, s12gn48 s12g64 s12g96 s12g128 s12g192 s12g240 0x00000- 0x003ff register space 0x00400- 0x005ff 0.5k 1k 1.5k 2k 3k 4k 4k 4k 0x00600- 0x007ff reserved eeprom 0x00800- 0x009ff 0x00a00- 0x00bff reserved 0x00c00- 0x00fff 0x01000- 0x013ff reserved 0x01400- 0x01fff unimplemented 0x02000- 0x2fff 0x03000- 0x037ff ram 0x03800- 0x03bff reserved 0x03c00- 0x03fff 1k 2k 4k 4k 8k 8k 11k 11k
s12g memory map controller (s12gmmcv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 279 5.4.4 prioritization of memory accesses on s12g devices, the cpu and the bdm are not able to access the memory in parallel. an arbitration occurs whenever both modules attempt a memory access at the same time. cpu accesses are handled with higher priority than bdm accesses unless the bdm module has been stalled for more then 128 bus cycles. in this case the pending bdm access will be processed immediately. 5.4.5 interrupts the s12gmmc does not generate any interrupts. 0x04000- 0x07fff ( nvmres=1) internal nvm resources (for details refer to section ftmrg) 0x04000- 0x07fff ( nvmres=0) reserved 0x08000- 0x0ffff 0x08000- 0x1ffff unimplemented 0x20000- 0x27fff reserved 0x28000- 0x2ffff 0x30000- 0x33fff reserved 0x34000- 0x37fff flash 0x38000- 0x3bfff reserved 0x3c000- 0x3ffff 16k 32k 48k 64k 96k 128k 192k 240k table 5-8. global address ranges s12gn16 s12gn32 s12g48, s12gn48 s12g64 s12g96 s12g128 s12g192 s12g240
s12g memory map controller (s12gmmcv1) mc9s12g family reference manual, rev.1.23 280 freescale semiconductor
mc9s12g family reference manual, rev.1.23 freescale semiconductor 281 chapter 6 interrupt module (s12sintv1) 6.1 introduction the int module decodes the priority of all system exception requests and provides the applicable vector for processing the exception to the cpu. the int module supports: i bit and x bit maskable interrupt requests a non-maskable unimplemented op-code trap a non-maskable software interrupt (swi) or background debug mode request three system reset vector requests a spurious interrupt vector each of the i bit maskable interrupt requests is assigned to a ?ed priority level. 6.1.1 glossary table 6-2 contains terms and abbreviations used in the document. 6.1.2 features interrupt vector base register (ivbr) one spurious interrupt vector (at address vector base 1 + 0x0080). version number revision date effective date author description of changes 01.02 13 sep 2007 updates for s12p family devices: - re-added xirq and irq references since this functionality is used on devices without d2d - added low voltage reset as possible source to the pin reset vector 01.03 21 nov 2007 added clari?ation of ?ake-up from stop or wait by xirq with x bit set?feature 01.04 20 may 2009 added footnote about availability of ?ake-up from stop or wait by xirq with x bit set?feature table 6-2. terminology term meaning ccr condition code register (in the cpu) isr interrupt service routine mcu micro-controller unit
interrupt module (s12sintv1) mc9s12g family reference manual, rev.1.23 282 freescale semiconductor 2?8 i bit maskable interrupt vector requests (at addresses vector base + 0x0082?x00f2). i bit maskable interrupts can be nested. one x bit maskable interrupt vector request (at address vector base + 0x00f4). one non-maskable software interrupt request (swi) or background debug mode vector request (at address vector base + 0x00f6). one non-maskable unimplemented op-code trap (trap) vector (at address vector base + 0x00f8). three system reset vectors (at addresses 0xfffa?xfffe). determines the highest priority interrupt vector requests, drives the vector to the bus on cpu request wakes up the system from stop or wait mode when an appropriate interrupt request occurs. 6.1.3 modes of operation run mode this is the basic mode of operation. wait mode in wait mode, the clock to the int module is disabled. the int module is however capable of waking-up the cpu from wait mode if an interrupt occurs. please refer to section 6.5.3, ?ake up from stop or wait mode for details. stop mode in stop mode, the clock to the int module is disabled. the int module is however capable of waking-up the cpu from stop mode if an interrupt occurs. please refer to section 6.5.3, ?ake up from stop or wait mode for details. freeze mode (bdm active) in freeze mode (bdm active), the interrupt vector base register is overridden internally. please refer to section 6.3.1.1, ?nterrupt vector base register (ivbr) for details. 6.1.4 block diagram figure 6-1 shows a block diagram of the int module. 1. the vector base is a 16-bit address which is accumulated from the contents of the interrupt vector base register (ivbr, used as upper byte) and 0x00 (used as lower byte).
interrupt module (s12sintv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 283 figure 6-1. int block diagram 6.2 external signal description the int module has no external signals. 6.3 memory map and register de?ition this section provides a detailed description of all registers accessible in the int module. 6.3.1 register descriptions this section describes in address order all the int registers and their individual bits. 6.3.1.1 interrupt vector base register (ivbr) read: anytime write: anytime address: 0x0120 76543210 r ivb_addr[7:0] w reset 11111111 figure 6-2. interrupt vector base register (ivbr) wake up ivbr interrupt requests interrupt requests cpu vector address peripheral to cpu priority decoder non i bit maskable channels i bit maskable channels
interrupt module (s12sintv1) mc9s12g family reference manual, rev.1.23 284 freescale semiconductor 6.4 functional description the int module processes all exception requests to be serviced by the cpu module. these exceptions include interrupt vector requests and reset vector requests. each of these exception types and their overall priority level is discussed in the subsections below. 6.4.1 s12s exception requests the cpu handles both reset requests and interrupt requests. a priority decoder is used to evaluate the priority of pending interrupt requests. 6.4.2 interrupt prioritization the int module contains a priority decoder to determine the priority for all interrupt requests pending for the cpu. if more than one interrupt request is pending, the interrupt request with the higher vector address wins the prioritization. the following conditions must be met for an i bit maskable interrupt request to be processed. 1. the local interrupt enabled bit in the peripheral module must be set. 2. the i bit in the condition code register (ccr) of the cpu must be cleared. 3. there is no swi, trap, or x bit maskable request pending. note all non i bit maskable interrupt requests always have higher priority than the i bit maskable interrupt requests. if the x bit in the ccr is cleared, it is possible to interrupt an i bit maskable interrupt by an x bit maskable interrupt. it is possible to nest non maskable interrupt requests, for example by nesting swi or trap calls. since an interrupt vector is only supplied at the time when the cpu requests it, it is possible that a higher priority interrupt request could override the original interrupt request that caused the cpu to request the vector. in this case, the cpu will receive the highest priority vector and the system will process this interrupt request ?st, before the original interrupt request is processed. table 6-3. ivbr field descriptions field description 7? ivb_addr[7:0] interrupt vector base address bits these bits represent the upper byte of all vector addresses. out of reset these bits are set to 0xff (that means vectors are located at 0xff80?xfffe) to ensure compatibility to hcs12. note: a system reset will initialize the interrupt vector base register with ?xff before it is used to determine the reset vector address. therefore, changing the ivbr has no effect on the location of the three reset vectors (0xfffa?xfffe). note: if the bdm is active (that means the cpu is in the process of executing bdm ?mware code), the contents of ivbr are ignored and the upper byte of the vector address is ?ed as ?xff? this is done to enable handling of all non-maskable interrupts in the bdm ?mware.
interrupt module (s12sintv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 285 if the interrupt source is unknown (for example, in the case where an interrupt request becomes inactive after the interrupt has been recognized, but prior to the cpu vector request), the vector address supplied to the cpu will default to that of the spurious interrupt vector. note care must be taken to ensure that all interrupt requests remain active until the system begins execution of the applicable service routine; otherwise, the exception request may not get processed at all or the result may be a spurious interrupt request (vector at address (vector base + 0x0080)). 6.4.3 reset exception requests the int module supports three system reset exception request types (please refer to the clock and reset generator module for details): 1. pin reset, power-on reset or illegal address reset, low voltage reset (if applicable) 2. clock monitor reset request 3. cop watchdog reset request 6.4.4 exception priority the priority (from highest to lowest) and address of all exception vectors issued by the int module upon request by the cpu is shown in table 6-4 . table 6-4. exception vector map and priority vector address 1 1 16 bits vector address based source 0xfffe pin reset, power-on reset, illegal address reset, low voltage reset (if applicable) 0xfffc clock monitor reset 0xfffa cop watchdog reset (vector base + 0x00f8) unimplemented opcode trap (vector base + 0x00f6) software interrupt instruction (swi) or bdm vector request (vector base + 0x00f4) x bit maskable interrupt request (xirq or d2d error interrupt) 2 2 d2d error interrupt on mcus featuring a d2d initiator module, otherwise xirq pin interrupt (vector base + 0x00f2) irq or d2d interrupt request 3 3 d2d interrupt on mcus featuring a d2d initiator module, otherwise irq pin interrupt (vector base + 0x00f0?x0082) device speci? i bit maskable interrupt sources (priority determined by the low byte of the vector address, in descending order) (vector base + 0x0080) spurious interrupt
interrupt module (s12sintv1) mc9s12g family reference manual, rev.1.23 286 freescale semiconductor 6.5 initialization/application information 6.5.1 initialization after system reset, software should: 1. initialize the interrupt vector base register if the interrupt vector table is not located at the default location (0xff80?xfff9). 2. enable i bit maskable interrupts by clearing the i bit in the ccr. 3. enable the x bit maskable interrupt by clearing the x bit in the ccr. 6.5.2 interrupt nesting the interrupt request scheme makes it possible to nest i bit maskable interrupt requests handled by the cpu. i bit maskable interrupt requests can be interrupted by an interrupt request with a higher priority. i bit maskable interrupt requests cannot be interrupted by other i bit maskable interrupt requests per default. in order to make an interrupt service routine (isr) interruptible, the isr must explicitly clear the i bit in the ccr (cli). after clearing the i bit, other i bit maskable interrupt requests can interrupt the current isr. an isr of an interruptible i bit maskable interrupt request could basically look like this: 1. service interrupt, that is clear interrupt ?gs, copy data, etc. 2. clear i bit in the ccr by executing the instruction cli (thus allowing other i bit maskable interrupt requests) 3. process data 4. return from interrupt by executing the instruction rti 6.5.3 wake up from stop or wait mode 6.5.3.1 cpu wake up from stop or wait mode every i bit maskable interrupt request is capable of waking the mcu from stop or wait mode. to determine whether an i bit maskable interrupts is quali?d to wake-up the cpu or not, the same conditions as in normal run mode are applied during stop or wait mode: if the i bit in the ccr is set, all i bit maskable interrupts are masked from waking-up the mcu. since there are no clocks running in stop mode, only interrupts which can be asserted asynchronously can wake-up the mcu from stop mode. the x bit maskable interrupt request can wake up the mcu from stop or wait mode at anytime, even if the x bit in ccr is set 1 . 1. the capability of the xirq pin to wake-up the mcu with the x bit set may not be available if, for example, the xirq pin is shared with other peripheral modules on the device. please refer to the device section of the mcu reference manual for details.
interrupt module (s12sintv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 287 if the x bit maskable interrupt request is used to wake-up the mcu with the x bit in the ccr set, the associated isr is not called. the cpu then resumes program execution with the instruction following the wai or stop instruction. this features works following the same rules like any interrupt request, that is care must be taken that the x interrupt request used for wake-up remains active at least until the system begins execution of the instruction following the wai or stop instruction; otherwise, wake-up may not occur.
interrupt module (s12sintv1) mc9s12g family reference manual, rev.1.23 288 freescale semiconductor
mc9s12g family reference manual, rev.1.23 freescale semiconductor 289 chapter 7 background debug module (s12sbdmv1) table 7-1. revision history 7.1 introduction this section describes the functionality of the background debug module (bdm) sub-block of the hcs12s core platform. the background debug module (bdm) sub-block is a single-wire, background debug system implemented in on-chip hardware for minimal cpu intervention. all interfacing with the bdm is done via the bkgd pin. the bdm has enhanced capability for maintaining synchronization between the target and host while allowing more ?xibility in clock rates. this includes a sync signal to determine the communication rate and a handshake signal to indicate when an operation is complete. the system is backwards compatible to the bdm of the s12 family with the following exceptions: taggo command not supported by s12sbdm external instruction tagging feature is part of the dbg module s12sbdm register map and register content modi?d family id readable from bdm rom at global address 0x3_ff0f in active bdm (value for devices with hcs12s core is 0xc2) clock switch removed from bdm (clksw bit removed from bdmsts register) 7.1.1 features the bdm includes these distinctive features: single-wire communication with host development system enhanced capability for allowing more ?xibility in clock rates sync command to determine communication rate revision number date sections affected summary of changes 1.03 14.may.2009 internal conditional text only 1.04 30.nov.2009 internal conditional text only 1.05 07.dec.2010 standardized format of revision history table header. 1.06 02.mar.2011 7.3.2.2/7-295 7.2/7-291 corrected bpae bit description. removed references to ?ed vco frequencies
background debug module (s12sbdmv1) mc9s12g family reference manual, rev.1.23 290 freescale semiconductor go_until command hardware handshake protocol to increase the performance of the serial communication active out of reset in special single chip mode nine hardware commands using free cycles, if available, for minimal cpu intervention hardware commands not requiring active bdm 14 ?mware commands execute from the standard bdm ?mware lookup table software control of bdm operation during wait mode when secured, hardware commands are allowed to access the register space in special single chip mode, if the flash erase tests fail. family id readable from bdm rom at global address 0x3_ff0f in active bdm (value for devices with hcs12s core is 0xc2) bdm hardware commands are operational until system stop mode is entered 7.1.2 modes of operation bdm is available in all operating modes but must be enabled before ?mware commands are executed. some systems may have a control bit that allows suspending the function during background debug mode. 7.1.2.1 regular run modes all of these operations refer to the part in run mode and not being secured. the bdm does not provide controls to conserve power during run mode. normal modes general operation of the bdm is available and operates the same in all normal modes. special single chip mode in special single chip mode, background operation is enabled and active out of reset. this allows programming a system with blank memory. 7.1.2.2 secure mode operation if the device is in secure mode, the operation of the bdm is reduced to a small subset of its regular run mode operation. secure operation prevents access to flash other than allowing erasure. for more information please see section 7.4.1, ?ecurity . 7.1.2.3 low-power modes the bdm can be used until stop mode is entered. when cpu is in wait mode all bdm ?mware commands as well as the hardware background command cannot be used and are ignored. in this case the cpu can not enter bdm active mode, and only hardware read and write commands are available. also the cpu can not enter a low power mode (stop or wait) during bdm active mode. in stop mode the bdm clocks are stopped. when bdm clocks are disabled and stop mode is exited, the bdm clocks will restart and bdm will have a soft reset (clearing the instruction register, any command in progress and disable the ack function). the bdm is now ready to receive a new command.
background debug module (s12sbdmv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 291 7.1.3 block diagram a block diagram of the bdm is shown in figure 7-1 . figure 7-1. bdm block diagram 7.2 external signal description a single-wire interface pin called the background debug interface (bkgd) pin is used to communicate with the bdm system. during reset, this pin is a mode select input which selects between normal and special modes of operation. after reset, this pin becomes the dedicated serial interface pin for the background debug mode. the communication rate of this pin is always the bdm clock frequency de?ed at device level (refer to device overview section). when modifying the vco clock please make sure that the communication rate is adapted accordingly and a communication time-out (bdm soft reset) has occurred. 7.3 memory map and register de?ition 7.3.1 module memory map table 7-2 shows the bdm memory map when bdm is active. 16-bit shift register bkgd host system serial interface data control register block register bdmsts instruction code and execution standard bdm firmware lookup table secured bdm firmware lookup table bus interface and control logic address data control clocks bdmact trace enbdm sdv unsec
background debug module (s12sbdmv1) mc9s12g family reference manual, rev.1.23 292 freescale semiconductor 7.3.2 register descriptions a summary of the registers associated with the bdm is shown in figure 7-2 . registers are accessed by host-driven communications to the bdm hardware using read_bd and write_bd commands. table 7-2. bdm memory map global address module size (bytes) 0x3_ff00?x3_ff0b bdm registers 12 0x3_ff0c?x3_ff0e bdm ?mware rom 3 0x3_ff0f family id (part of bdm ?mware rom) 1 0x3_ff10?x3_ffff bdm ?mware rom 240 global address register name bit 7 6 5 4 3 2 1 bit 0 0x3_ff00 reserved r x x x x x x 0 0 w 0x3_ff01 bdmsts r enbdm bdmact 0 sdv trace 0 unsec 0 w 0x3_ff02 reserved r x x x x x x x x w 0x3_ff03 reserved r x x x x x x x x w 0x3_ff04 reserved r x x x x x x x x w 0x3_ff05 reserved r x x x x x x x x w 0x3_ff06 bdmccr r ccr7 ccr6 ccr5 ccr4 ccr3 ccr2 ccr1 ccr0 w 0x3_ff07 reserved r 0 0 0 0 0 0 0 0 w = unimplemented, reserved = implemented (do not alter) x = indeterminate 0 = always read zero figure 7-2. bdm register summary
background debug module (s12sbdmv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 293 7.3.2.1 bdm status register (bdmsts) figure 7-3. bdm status register ( bdmsts) read: all modes through bdm operation when not secured write: all modes through bdm operation when not secured, but subject to the following: enbdm should only be set via a bdm hardware command if the bdm ?mware commands are needed. (this does not apply in special single chip mode). bdmact can only be set by bdm hardware upon entry into bdm. it can only be cleared by the standard bdm ?mware lookup table upon exit from bdm active mode. 0x3_ff08 bdmppr r bpae 000 bpp3 bpp2 bpp1 bpp0 w 0x3_ff09 reserved r 0 0 0 0 0 0 0 0 w 0x3_ff0a reserved r 0 0 0 0 0 0 0 0 w 0x3_ff0b reserved r 0 0 0 0 0 0 0 0 w register global address 0x3_ff01 7 6 54 3 2 1 0 r enbdm bdmact 0sdv trace 0 unsec 0 w reset special single-chip mode 0 1 1 enbdm is read as 1 by a debugging environment in special single chip mode when the device is not secured or secured but fully erased (flash). this is because the enbdm bit is set by the standard bdm ?mware before a bdm command can be fully transmitted and executed. 1 00 0 0 0 2 2 unsec is read as 1 by a debugging environment in special single chip mode when the device is secured and fully erased, else it is 0 and can only be read if not secure (see also bit description). 0 all other modes 0 0 00 0 0 0 0 = unimplemented, reserved = implemented (do not alter) 0 = always read zero global address register name bit 7 6 5 4 3 2 1 bit 0 = unimplemented, reserved = implemented (do not alter) x = indeterminate 0 = always read zero figure 7-2. bdm register summary (continued)
background debug module (s12sbdmv1) mc9s12g family reference manual, rev.1.23 294 freescale semiconductor all other bits, while writable via bdm hardware or standard bdm ?mware write commands, should only be altered by the bdm hardware or standard ?mware lookup table as part of bdm command execution. table 7-3. bdmsts field descriptions field description 7 enbdm enable bdm ?this bit controls whether the bdm is enabled or disabled. when enabled, bdm can be made active to allow ?mware commands to be executed. when disabled, bdm cannot be made active but bdm hardware commands are still allowed. 0 bdm disabled 1 bdm enabled note: enbdm is set out of reset in special single chip mode. in special single chip mode with the device secured, this bit will not be set until after the flash erase verify tests are complete. 6 bdmact bdm active status ?this bit becomes set upon entering bdm. the standard bdm ?mware lookup table is then enabled and put into the memory map. bdmact is cleared by a carefully timed store instruction in the standard bdm ?mware as part of the exit sequence to return to user code and remove the bdm memory from the map. 0 bdm not active 1 bdm active 4 sdv shift data valid this bit is set and cleared by the bdm hardware. it is set after data has been transmitted as part of a bdm ?mware or hardware read command or after data has been received as part of a bdm ?mware or hardware write command. it is cleared when the next bdm command has been received or bdm is exited. sdv is used by the standard bdm ?mware to control program ?w execution. 0 data phase of command not complete 1 data phase of command is complete 3 trace trace1 bdm firmware command is being executed ?this bit gets set when a bdm trace1 ?mware command is ?st recognized. it will stay set until bdm ?mware is exited by one of the following bdm commands: go or go_until. 0 trace1 command is not being executed 1 trace1 command is being executed 1 unsec unsecure ?if the device is secured this bit is only writable in special single chip mode from the bdm secure ?mware. it is in a zero state as secure mode is entered so that the secure bdm ?mware lookup table is enabled and put into the memory map overlapping the standard bdm ?mware lookup table. the secure bdm ?mware lookup table veri?s that the on-chip flash is erased. this being the case, the unsec bit is set and the bdm program jumps to the start of the standard bdm ?mware lookup table and the secure bdm ?mware lookup table is turned off. if the erase test fails, the unsec bit will not be asserted. 0 system is in a secured mode. 1 system is in a unsecured mode. note: when unsec is set, security is off and the user can change the state of the secure bits in the on-chip flash eeprom. note that if the user does not change the state of the bits to ?nsecured?mode, the system will be secured again when it is next taken out of reset.after reset this bit has no meaning or effect when the security byte in the flash eeprom is con?ured for unsecure mode.
background debug module (s12sbdmv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 295 figure 7-4. bdm ccr holding register (bdmccr) read: all modes through bdm operation when not secured write: all modes through bdm operation when not secured note when bdm is made active, the cpu stores the content of its ccr register in the bdmccr register. however, out of special single-chip reset, the bdmccr is set to 0xd8 and not 0xd0 which is the reset value of the ccr register in this cpu mode. out of reset in all other modes the bdmccr register is read zero. when entering background debug mode, the bdm ccr holding register is used to save the condition code register of the users program. it is also used for temporary storage in the standard bdm ?mware mode. the bdm ccr holding register can be written to modify the ccr value. 7.3.2.2 bdm program page index register (bdmppr) figure 7-5. bdm program page register (bdmppr) read: all modes through bdm operation when not secured write: all modes through bdm operation when not secured register global address 0x3_ff06 7 6 5 4 3 2 1 0 r ccr7 ccr6 ccr5 ccr4 ccr3 ccr2 ccr1 ccr0 w reset special single-chip mode 1 1 0 0 1 0 0 0 all other modes 0 0 0 0 0 0 0 0 register global address 0x3_ff08 7 6 5 4 3 2 1 0 r bpae 0 0 0 bpp3 bpp2 bpp1 bpp0 w reset 0 0 0 0 0 0 0 0 = unimplemented, reserved table 7-4. bdmppr field descriptions field description 7 bpae bdm program page access enable bit ?bpae enables program page access for bdm hardware and ?mware read/write instructions the bdm hardware commands used to access the bdm registers (read_bd and write_bd) can not be used for program page accesses even if the bpae bit is set. 0 bdm program paging disabled 1 bdm program paging enabled 3? bpp[3:0] bdm program page index bits 3? ?these bits de?e the selected program page. for more detailed information regarding the program page window scheme, please refer to the s12s_mmc block guide.
background debug module (s12sbdmv1) mc9s12g family reference manual, rev.1.23 296 freescale semiconductor 7.3.3 family id assignment the family id is an 8-bit value located in the bdm rom in active bdm (at global address: 0x3_ff0f). the read-only value is a unique family id which is 0xc2 for devices with an hcs12s core. 7.4 functional description the bdm receives and executes commands from a host via a single wire serial interface. there are two types of bdm commands: hardware and ?mware commands. hardware commands are used to read and write target system memory locations and to enter active background debug mode, see section 7.4.3, ?dm hardware commands . target system memory includes all memory that is accessible by the cpu. firmware commands are used to read and write cpu resources and to exit from active background debug mode, see section 7.4.4, ?tandard bdm firmware commands . the cpu resources referred to are the accumulator (d), x index register (x), y index register (y), stack pointer (sp), and program counter (pc). hardware commands can be executed at any time and in any mode excluding a few exceptions as highlighted (see section 7.4.3, ?dm hardware commands ) and in secure mode (see section 7.4.1, ?ecurity ). bdm ?mware commands can only be executed when the system is not secure and is in active background debug mode (bdm). 7.4.1 security if the user resets into special single chip mode with the system secured, a secured mode bdm ?mware lookup table is brought into the map overlapping a portion of the standard bdm ?mware lookup table. the secure bdm ?mware veri?s that the on-chip flash eeprom are erased. this being the case, the unsec and enbdm bit will get set. the bdm program jumps to the start of the standard bdm ?mware and the secured mode bdm ?mware is turned off and all bdm commands are allowed. if the flash does not verify as erased, the bdm ?mware sets the enbdm bit, without asserting unsec, and the ?mware enters a loop. this causes the bdm hardware commands to become enabled, but does not enable the ?mware commands. this allows the bdm hardware to be used to erase the flash. bdm operation is not possible in any other mode than special single chip mode when the device is secured. the device can only be unsecured via bdm serial interface in special single chip mode. for more information regarding security, please see the s12s_9sec block guide. 7.4.2 enabling and activating bdm the system must be in active bdm to execute standard bdm ?mware commands. bdm can be activated only after being enabled. bdm is enabled by setting the enbdm bit in the bdm status (bdmsts) register. the enbdm bit is set by writing to the bdm status (bdmsts) register, via the single-wire interface, using a hardware command such as write_bd_byte. after being enabled, bdm is activated by one of the following 1 : 1. bdm is enabled and active immediately out of special single-chip reset.
background debug module (s12sbdmv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 297 hardware background command cpu bgnd instruction breakpoint force or tag mechanism 1 when bdm is activated, the cpu ?ishes executing the current instruction and then begins executing the ?mware in the standard bdm ?mware lookup table. when bdm is activated by a breakpoint, the type of breakpoint used determines if bdm becomes active before or after execution of the next instruction. note if an attempt is made to activate bdm before being enabled, the cpu resumes normal instruction execution after a brief delay. if bdm is not enabled, any hardware background commands issued are ignored by the bdm and the cpu is not delayed. in active bdm, the bdm registers and standard bdm ?mware lookup table are mapped to addresses 0x3_ff00 to 0x3_ffff. bdm registers are mapped to addresses 0x3_ff00 to 0x3_ff0b. the bdm uses these registers which are readable anytime by the bdm. however, these registers are not readable by user programs. when bdm is activated while cpu executes code overlapping with bdm ?mware space the saved program counter (pc) will be auto incremented by one from the bdm ?mware, no matter what caused the entry into bdm active mode (bgnd instruction, background command or breakpoints). in such a case the pc must be set to the next valid address via a write_pc command before executing the go command. 7.4.3 bdm hardware commands hardware commands are used to read and write target system memory locations and to enter active background debug mode. target system memory includes all memory that is accessible by the cpu such as on-chip ram, flash, i/o and control registers. hardware commands are executed with minimal or no cpu intervention and do not require the system to be in active bdm for execution, although, they can still be executed in this mode. when executing a hardware command, the bdm sub-block waits for a free bus cycle so that the background access does not disturb the running application program. if a free cycle is not found within 128 clock cycles, the cpu is momentarily frozen so that the bdm can steal a cycle. when the bdm ?ds a free cycle, the operation does not intrude on normal cpu operation provided that it can be completed in a single cycle. however, if an operation requires multiple cycles the cpu is frozen until the operation is complete, even though the bdm found a free cycle. the bdm hardware commands are listed in table 7-5 . the read_bd and write_bd commands allow access to the bdm register locations. these locations are not normally in the system memory map but share addresses with the application in memory. to distinguish between physical memory locations that share the same address, bdm memory resources are 1. this method is provided by the s12s_dbg module.
background debug module (s12sbdmv1) mc9s12g family reference manual, rev.1.23 298 freescale semiconductor enabled just for the read_bd and write_bd access cycle. this allows the bdm to access bdm locations unobtrusively, even if the addresses con?ct with the application memory map. 7.4.4 standard bdm firmware commands bdm ?mware commands are used to access and manipulate cpu resources. the system must be in active bdm to execute standard bdm ?mware commands, see section 7.4.2, ?nabling and activating bdm . normal instruction execution is suspended while the cpu executes the ?mware located in the standard bdm ?mware lookup table. the hardware command background is the usual way to activate bdm. as the system enters active bdm, the standard bdm ?mware lookup table and bdm registers become visible in the on-chip memory map at 0x3_ff00?x3_ffff, and the cpu begins executing the standard bdm ?mware. the standard bdm ?mware watches for serial commands and executes them as they are received. the ?mware commands are shown in table 7-6 . table 7-5. hardware commands command opcode (hex) data description background 90 none enter background mode if bdm is enabled. if enabled, an ack will be issued when the part enters active background mode. ack_enable d5 none enable handshake. issues an ack pulse after the command is executed. ack_disable d6 none disable handshake. this command does not issue an ack pulse. read_bd_byte e4 16-bit address 16-bit data out read from memory with standard bdm ?mware lookup table in map. odd address data on low byte; even address data on high byte. read_bd_word ec 16-bit address 16-bit data out read from memory with standard bdm ?mware lookup table in map. must be aligned access. read_byte e0 16-bit address 16-bit data out read from memory with standard bdm ?mware lookup table out of map. odd address data on low byte; even address data on high byte. read_word e8 16-bit address 16-bit data out read from memory with standard bdm ?mware lookup table out of map. must be aligned access. write_bd_byte c4 16-bit address 16-bit data in write to memory with standard bdm ?mware lookup table in map. odd address data on low byte; even address data on high byte. write_bd_word cc 16-bit address 16-bit data in write to memory with standard bdm ?mware lookup table in map. must be aligned access. write_byte c0 16-bit address 16-bit data in write to memory with standard bdm ?mware lookup table out of map. odd address data on low byte; even address data on high byte. write_word c8 16-bit address 16-bit data in write to memory with standard bdm ?mware lookup table out of map. must be aligned access. note: if enabled, ack will occur when data is ready for transmission for all bdm read commands and will occur after the write is complete for all bdm write commands.
background debug module (s12sbdmv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 299 7.4.5 bdm command structure hardware and ?mware bdm commands start with an 8-bit opcode followed by a 16-bit address and/or a 16-bit data word, depending on the command. all the read commands return 16 bits of data despite the byte or word implication in the command name. 8-bit reads return 16-bits of data, only one byte of which contains valid data. if reading an even address, the valid data will appear in the msb. if reading an odd address, the valid data will appear in the lsb. table 7-6. firmware commands command 1 1 if enabled, ack will occur when data is ready for transmission for all bdm read commands and will occur after the write is complete for all bdm write commands. opcode (hex) data description read_next 2 2 when the ?mware command read_next or write_next is used to access the bdm address space the bdm resources are accessed rather than user code. writing bdm ?mware is not possible. 62 16-bit data out increment x index register by 2 (x = x + 2), then read word x points to. read_pc 63 16-bit data out read program counter. read_d 64 16-bit data out read d accumulator. read_x 65 16-bit data out read x index register. read_y 66 16-bit data out read y index register. read_sp 67 16-bit data out read stack pointer. write_next 2 42 16-bit data in increment x index register by 2 (x = x + 2), then write word to location pointed to by x. write_pc 43 16-bit data in write program counter. write_d 44 16-bit data in write d accumulator. write_x 45 16-bit data in write x index register. write_y 46 16-bit data in write y index register. write_sp 47 16-bit data in write stack pointer. go 08 none go to user program. if enabled, ack will occur when leaving active background mode. go_until 3 3 system stop disables the ack function and ignored commands will not have an ack-pulse (e.g., cpu in stop or wait mode). the go_until command will not get an acknowledge if cpu executes the wait or stop instruction before the ?ntil condition (bdm active again) is reached (see section 7.4.7, ?erial interface hardware handshake protocol last note). 0c none go to user program. if enabled, ack will occur upon returning to active background mode. trace1 10 none execute one user instruction then return to active bdm. if enabled, ack will occur upon returning to active background mode. taggo -> go 18 none (previous enable tagging and go to user program.) this command will be deprecated and should not be used anymore. opcode will be executed as a go command.
background debug module (s12sbdmv1) mc9s12g family reference manual, rev.1.23 300 freescale semiconductor 16-bit misaligned reads and writes are generally not allowed. if attempted by bdm hardware command, the bdm ignores the least signi?ant bit of the address and assumes an even address from the remaining bits. for hardware data read commands, the external host must wait at least 150 bus clock cycles after sending the address before attempting to obtain the read data. this is to be certain that valid data is available in the bdm shift register, ready to be shifted out. for hardware write commands, the external host must wait 150 bus clock cycles after sending the data to be written before attempting to send a new command. this is to avoid disturbing the bdm shift register before the write has been completed. the 150 bus clock cycle delay in both cases includes the maximum 128 cycle delay that can be incurred as the bdm waits for a free cycle before stealing a cycle. for bdm ?mware read commands, the external host should wait at least 48 bus clock cycles after sending the command opcode and before attempting to obtain the read data. the 48 cycle wait allows enough time for the requested data to be made available in the bdm shift register, ready to be shifted out. for bdm ?mware write commands, the external host must wait 36 bus clock cycles after sending the data to be written before attempting to send a new command. this is to avoid disturbing the bdm shift register before the write has been completed. the external host should wait for at least for 76 bus clock cycles after a trace1 or go command before starting any new serial command. this is to allow the cpu to exit gracefully from the standard bdm ?mware lookup table and resume execution of the user code. disturbing the bdm shift register prematurely may adversely affect the exit from the standard bdm ?mware lookup table. note if the bus rate of the target processor is unknown or could be changing, it is recommended that the ack (acknowledge function) is used to indicate when an operation is complete. when using ack, the delay times are automated. figure 7-6 represents the bdm command structure. the command blocks illustrate a series of eight bit times starting with a falling edge. the bar across the top of the blocks indicates that the bkgd line idles in the high state. the time for an 8-bit command is 8 16 target clock cycles. 1 1. target clock cycles are cycles measured using the target mcus serial clock rate. see section 7.4.6, ?dm serial interface and section 7.3.2.1, ?dm status register (bdmsts) for information on how serial clock rate is selected.
background debug module (s12sbdmv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 301 figure 7-6. bdm command structure 7.4.6 bdm serial interface the bdm communicates with external devices serially via the bkgd pin. during reset, this pin is a mode select input which selects between normal and special modes of operation. after reset, this pin becomes the dedicated serial interface pin for the bdm. the bdm serial interface is timed based on the vco clock (please refer to the cpmu block guide for more details), which gets divided by 8. this clock will be referred to as the target clock in the following explanation. the bdm serial interface uses a clocking scheme in which the external host generates a falling edge on the bkgd pin to indicate the start of each bit time. this falling edge is sent for every bit whether data is transmitted or received. data is transferred most signi?ant bit (msb) ?st at 16 target clock cycles per bit. the interface times out if 512 clock cycles occur between falling edges from the host. the bkgd pin is a pseudo open-drain pin and has an weak on-chip active pull-up that is enabled at all times. it is assumed that there is an external pull-up and that drivers connected to bkgd do not typically drive the high level. since r-c rise time could be unacceptably long, the target system and host provide brief driven-high (speedup) pulses to drive bkgd to a logic 1. the source of this speedup pulse is the host for transmit cases and the target for receive cases. the timing for host-to-target is shown in figure 7-7 and that of target-to-host in figure 7-8 and figure 7-9 . all four cases begin when the host drives the bkgd pin low to generate a falling edge. since the host and target are operating from separate clocks, it can take the target system up to one full clock cycle to recognize this edge. the target measures delays from this perceived start of the bit time while the host measures delays from the point it actually drove bkgd low to start the bit up to one target clock cycle hardware hardware firmware firmware go, 48-bc bc = bus clock cycles command address 150-bc delay next delay 8 bits at ~ 16 tc/bit 16 bits at ~ 16 tc/bit 16 bits at ~ 16 tc/bit command address data next data read write read write trace command next command data 76-bc delay next command 150-bc delay 36-bc delay command command command command data next command tc = target clock cycles
background debug module (s12sbdmv1) mc9s12g family reference manual, rev.1.23 302 freescale semiconductor earlier. synchronization between the host and target is established in this manner at the start of every bit time. figure 7-7 shows an external host transmitting a logic 1 and transmitting a logic 0 to the bkgd pin of a target system. the host is asynchronous to the target, so there is up to a one clock-cycle delay from the host-generated falling edge to where the target recognizes this edge as the beginning of the bit time. ten target clock cycles later, the target senses the bit level on the bkgd pin. internal glitch detect logic requires the pin be driven high no later that eight target clock cycles after the falling edge for a logic 1 transmission. since the host drives the high speedup pulses in these two cases, the rising edges look like digitally driven signals. figure 7-7. bdm host-to-target serial bit timing the receive cases are more complicated. figure 7-8 shows the host receiving a logic 1 from the target system. since the host is asynchronous to the target, there is up to one clock-cycle delay from the host-generated falling edge on bkgd to the perceived start of the bit time in the target. the host holds the bkgd pin low long enough for the target to recognize it (at least two target clock cycles). the host must release the low drive before the target drives a brief high speedup pulse seven target clock cycles after the perceived start of the bit time. the host should sample the bit level about 10 target clock cycles after it started the bit time. target senses bit 10 cycles synchronization uncertainty bdm clock (target mcu) host transmit 1 host transmit 0 perceived start of bit time earliest start of next bit
background debug module (s12sbdmv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 303 figure 7-8. bdm target-to-host serial bit timing (logic 1) figure 7-9 shows the host receiving a logic 0 from the target. since the host is asynchronous to the target, there is up to a one clock-cycle delay from the host-generated falling edge on bkgd to the start of the bit time as perceived by the target. the host initiates the bit time but the target ?ishes it. since the target wants the host to receive a logic 0, it drives the bkgd pin low for 13 target clock cycles then brie? drives it high to speed up the rising edge. the host samples the bit level about 10 target clock cycles after starting the bit time. figure 7-9. bdm target-to-host serial bit timing (logic 0) high-impedance earliest start of next bit r-c rise 10 cycles 10 cycles host samples bkgd pin perceived start of bit time bkgd pin bdm clock (target mcu) host drive to bkgd pin target system speedup pulse high-impedance high-impedance earliest start of next bit bdm clock (target mcu) host drive to bkgd pin bkgd pin perceived start of bit time 10 cycles 10 cycles host samples bkgd pin target system drive and speedup pulse speedup pulse high-impedance
background debug module (s12sbdmv1) mc9s12g family reference manual, rev.1.23 304 freescale semiconductor 7.4.7 serial interface hardware handshake protocol bdm commands that require cpu execution are ultimately treated at the mcu bus rate. since the bdm clock source can be modi?d when changing the settings for the vco frequency (cpmusynr), it is very helpful to provide a handshake protocol in which the host could determine when an issued command is executed by the cpu. the bdm clock frequency is always vco frequency divided by 8. the alternative is to always wait the amount of time equal to the appropriate number of cycles at the slowest possible rate the clock could be running. this sub-section will describe the hardware handshake protocol. the hardware handshake protocol signals to the host controller when an issued command was successfully executed by the target. this protocol is implemented by a 16 serial clock cycle low pulse followed by a brief speedup pulse in the bkgd pin. this pulse is generated by the target mcu when a command, issued by the host, has been successfully executed (see figure 7-10 ). this pulse is referred to as the ack pulse. after the ack pulse has ?ished: the host can start the bit retrieval if the last issued command was a read command, or start a new command if the last command was a write command or a control command (background, go, go_until or trace1). the ack pulse is not issued earlier than 32 serial clock cycles after the bdm command was issued. the end of the bdm command is assumed to be the 16th tick of the last bit. this minimum delay assures enough time for the host to perceive the ack pulse. note also that, there is no upper limit for the delay between the command and the related ack pulse, since the command execution depends upon the cpu bus, which in some cases could be very slow due to long accesses taking place.this protocol allows a great ?xibility for the pod designers, since it does not rely on any accurate time measurement or short response time to any event in the serial communication. figure 7-10. target acknowledge pulse (ack) note if the ack pulse was issued by the target, the host assumes the previous command was executed. if the cpu enters wait or stop prior to executing a hardware command, the ack pulse will not be issued meaning that the bdm command was not executed. after entering wait or stop mode, the bdm command is no longer pending. 16 cycles bdm clock (target mcu) target transmits ack pulse high-impedance bkgd pin minimum delay from the bdm command 32 cycles earliest start of next bit speedup pulse 16th tick of the last command bit high-impedance
background debug module (s12sbdmv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 305 figure 7-11 shows the ack handshake protocol in a command level timing diagram. the read_byte instruction is used as an example. first, the 8-bit instruction opcode is sent by the host, followed by the address of the memory location to be read. the target bdm decodes the instruction. a bus cycle is grabbed (free or stolen) by the bdm and it executes the read_byte operation. having retrieved the data, the bdm issues an ack pulse to the host controller, indicating that the addressed byte is ready to be retrieved. after detecting the ack pulse, the host initiates the byte retrieval process. note that data is sent in the form of a word and the host needs to determine which is the appropriate byte based on whether the address was odd or even. figure 7-11. handshake protocol at command level differently from the normal bit transfer (where the host initiates the transmission), the serial interface ack handshake pulse is initiated by the target mcu by issuing a negative edge in the bkgd pin. the hardware handshake protocol in figure 7-10 speci?s the timing when the bkgd pin is being driven, so the host should follow this timing constraint in order to avoid the risk of an electrical con?ct in the bkgd pin. note the only place the bkgd pin can have an electrical con?ct is when one side is driving low and the other side is issuing a speedup pulse (high). other ?ighs are pulled rather than driven. however, at low rates the time of the speedup pulse can become lengthy and so the potential con?ct time becomes longer as well. the ack handshake protocol does not support nested ack pulses. if a bdm command is not acknowledge by an ack pulse, the host needs to abort the pending command ?st in order to be able to issue a new bdm command. when the cpu enters wait or stop while the host issues a hardware command (e.g., write_byte), the target discards the incoming command due to the wait or stop being detected. therefore, the command is not acknowledged by the target, which means that the ack pulse will not be issued in this case. after a certain time the host (not aware of stop or wait) should decide to abort any possible pending ack pulse in order to be sure a new command can be issued. therefore, the protocol provides a mechanism in which a command, and its corresponding ack, can be aborted. read_byte bdm issues the bkgd pin byte address bdm executes the read_byte command host target host target bdm decodes the command ack pulse (out of scale) host target (2) bytes are retrieved new bdm command
background debug module (s12sbdmv1) mc9s12g family reference manual, rev.1.23 306 freescale semiconductor note the ack pulse does not provide a time out. this means for the go_until command that it can not be distinguished if a stop or wait has been executed (command discarded and ack not issued) or if the ?ntil?condition (bdm active) is just not reached yet. hence in any case where the ack pulse of a command is not issued the possible pending command should be aborted before issuing a new command. see the handshake abort procedure described in section 7.4.8, ?ardware handshake abort procedure . 7.4.8 hardware handshake abort procedure the abort procedure is based on the sync command. in order to abort a command, which had not issued the corresponding ack pulse, the host controller should generate a low pulse in the bkgd pin by driving it low for at least 128 serial clock cycles and then driving it high for one serial clock cycle, providing a speedup pulse. by detecting this long low pulse in the bkgd pin, the target executes the sync protocol, see section 7.4.9, ?ync ?request timed reference pulse , and assumes that the pending command and therefore the related ack pulse, are being aborted. therefore, after the sync protocol has been completed the host is free to issue new bdm commands. for bdm ?mware read or write commands it can not be guaranteed that the pending command is aborted when issuing a sync before the corresponding ack pulse. there is a short latency time from the time the read or write access begins until it is ?ished and the corresponding ack pulse is issued. the latency time depends on the ?mware read or write command that is issued and on the selected bus clock rate. when the sync command starts during this latency time the read or write command will not be aborted, but the corresponding ack pulse will be aborted. a pending go, trace1 or go_until command can not be aborted. only the corresponding ack pulse can be aborted by the sync command. although it is not recommended, the host could abort a pending bdm command by issuing a low pulse in the bkgd pin shorter than 128 serial clock cycles, which will not be interpreted as the sync command. the ack is actually aborted when a negative edge is perceived by the target in the bkgd pin. the short abort pulse should have at least 4 clock cycles keeping the bkgd pin low, in order to allow the negative edge to be detected by the target. in this case, the target will not execute the sync protocol but the pending command will be aborted along with the ack pulse. the potential problem with this abort procedure is when there is a con?ct between the ack pulse and the short abort pulse. in this case, the target may not perceive the abort pulse. the worst case is when the pending command is a read command (i.e., read_byte). if the abort pulse is not perceived by the target the host will attempt to send a new command after the abort pulse was issued, while the target expects the host to retrieve the accessed memory byte. in this case, host and target will run out of synchronism. however, if the command to be aborted is not a read command the short abort pulse could be used. after a command is aborted the target assumes the next negative edge, after the abort pulse, is the ?st bit of a new bdm command. note the details about the short abort pulse are being provided only as a reference for the reader to better understand the bdm internal behavior. it is not recommended that this procedure be used in a real application.
background debug module (s12sbdmv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 307 since the host knows the target serial clock frequency, the sync command (used to abort a command) does not need to consider the lower possible target frequency. in this case, the host could issue a sync very close to the 128 serial clock cycles length. providing a small overhead on the pulse length in order to assure the sync pulse will not be misinterpreted by the target. see section 7.4.9, ?ync ?request timed reference pulse . figure 7-12 shows a sync command being issued after a read_byte, which aborts the read_byte command. note that, after the command is aborted a new command could be issued by the host computer. figure 7-12. ack abort procedure at the command level note figure 7-12 does not represent the signals in a true timing scale figure 7-13 shows a con?ct between the ack pulse and the sync request pulse. this con?ct could occur if a pod device is connected to the target bkgd pin and the target is already in debug active mode. consider that the target cpu is executing a pending bdm command at the exact moment the pod is being connected to the bkgd pin. in this case, an ack pulse is issued along with the sync command. in this case, there is an electrical con?ct between the ack speedup pulse and the sync pulse. since this is not a probable situation, the protocol does not prevent this con?ct from happening. figure 7-13. ack pulse and sync request con?ct read_byte read_status bkgd pin memory address new bdm command new bdm command host target host target host target sync response from the target (out of scale) bdm decode and starts to execute the read_byte command read_byte cmd is aborted by the sync request (out of scale) bdm clock (target mcu) target mcu drives to bkgd pin bkgd pin 16 cycles speedup pulse high-impedance host drives sync to bkgd pin ack pulse host sync request pulse at least 128 cycles electrical con?ct host and target drive to bkgd pin
background debug module (s12sbdmv1) mc9s12g family reference manual, rev.1.23 308 freescale semiconductor note this information is being provided so that the mcu integrator will be aware that such a con?ct could occur. the hardware handshake protocol is enabled by the ack_enable and disabled by the ack_disable bdm commands. this provides backwards compatibility with the existing pod devices which are not able to execute the hardware handshake protocol. it also allows for new pod devices, that support the hardware handshake protocol, to freely communicate with the target device. if desired, without the need for waiting for the ack pulse. the commands are described as follows: ack_enable enables the hardware handshake protocol. the target will issue the ack pulse when a cpu command is executed by the cpu. the ack_enable command itself also has the ack pulse as a response. ack_disable disables the ack pulse protocol. in this case, the host needs to use the worst case delay time at the appropriate places in the protocol. the default state of the bdm after reset is hardware handshake protocol disabled. all the read commands will ack (if enabled) when the data bus cycle has completed and the data is then ready for reading out by the bkgd serial pin. all the write commands will ack (if enabled) after the data has been received by the bdm through the bkgd serial pin and when the data bus cycle is complete. see section 7.4.3, ?dm hardware commands and section 7.4.4, ?tandard bdm firmware commands for more information on the bdm commands. the ack_enable sends an ack pulse when the command has been completed. this feature could be used by the host to evaluate if the target supports the hardware handshake protocol. if an ack pulse is issued in response to this command, the host knows that the target supports the hardware handshake protocol. if the target does not support the hardware handshake protocol the ack pulse is not issued. in this case, the ack_enable command is ignored by the target since it is not recognized as a valid command. the background command will issue an ack pulse when the cpu changes from normal to background mode. the ack pulse related to this command could be aborted using the sync command. the go command will issue an ack pulse when the cpu exits from background mode. the ack pulse related to this command could be aborted using the sync command. the go_until command is equivalent to a go command with exception that the ack pulse, in this case, is issued when the cpu enters into background mode. this command is an alternative to the go command and should be used when the host wants to trace if a breakpoint match occurs and causes the cpu to enter active background mode. note that the ack is issued whenever the cpu enters bdm, which could be caused by a breakpoint match or by a bgnd instruction being executed. the ack pulse related to this command could be aborted using the sync command. the trace1 command has the related ack pulse issued when the cpu enters background active mode after one instruction of the application program is executed. the ack pulse related to this command could be aborted using the sync command.
background debug module (s12sbdmv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 309 7.4.9 sync ?request timed reference pulse the sync command is unlike other bdm commands because the host does not necessarily know the correct communication speed to use for bdm communications until after it has analyzed the response to the sync command. to issue a sync command, the host should perform the following steps: 1. drive the bkgd pin low for at least 128 cycles at the lowest possible bdm serial communication frequency (the lowest serial communication frequency is determined by the settings for the vco clock (cpmusynr). the bdm clock frequency is always vco clock frequency divided by 8.) 2. drive bkgd high for a brief speedup pulse to get a fast rise time (this speedup pulse is typically one cycle of the host clock.) 3. remove all drive to the bkgd pin so it reverts to high impedance. 4. listen to the bkgd pin for the sync response pulse. upon detecting the sync request from the host, the target performs the following steps: 1. discards any incomplete command received or bit retrieved. 2. waits for bkgd to return to a logic one. 3. delays 16 cycles to allow the host to stop driving the high speedup pulse. 4. drives bkgd low for 128 cycles at the current bdm serial communication frequency. 5. drives a one-cycle high speedup pulse to force a fast rise time on bkgd. 6. removes all drive to the bkgd pin so it reverts to high impedance. the host measures the low time of this 128 cycle sync response pulse and determines the correct speed for subsequent bdm communications. typically, the host can determine the correct communication speed within a few percent of the actual target speed and the communication protocol can easily tolerate speed errors of several percent. as soon as the sync request is detected by the target, any partially received command or bit retrieved is discarded. this is referred to as a soft-reset, equivalent to a time-out in the serial communication. after the sync response, the target will consider the next negative edge (issued by the host) as the start of a new bdm command or the start of new sync request. another use of the sync command pulse is to abort a pending ack pulse. the behavior is exactly the same as in a regular sync command. note that one of the possible causes for a command to not be acknowledged by the target is a host-target synchronization problem. in this case, the command may not have been understood by the target and so an ack response pulse will not be issued. 7.4.10 instruction tracing when a trace1 command is issued to the bdm in active bdm, the cpu exits the standard bdm ?mware and executes a single instruction in the user code. once this has occurred, the cpu is forced to return to the standard bdm ?mware and the bdm is active and ready to receive a new command. if the trace1 command is issued again, the next user instruction will be executed. this facilitates stepping or tracing through the user code one instruction at a time.
background debug module (s12sbdmv1) mc9s12g family reference manual, rev.1.23 310 freescale semiconductor if an interrupt is pending when a trace1 command is issued, the interrupt stacking operation occurs but no user instruction is executed. once back in standard bdm ?mware execution, the program counter points to the ?st instruction in the interrupt service routine. be aware when tracing through the user code that the execution of the user code is done step by step but all peripherals are free running. hence possible timing relations between cpu code execution and occurrence of events of other peripherals no longer exist. do not trace the cpu instruction bgnd used for soft breakpoints. tracing over the bgnd instruction will result in a return address pointing to bdm ?mware address space. when tracing through user code which contains stop or wait instructions the following will happen when the stop or wait instruction is traced: the cpu enters stop or wait mode and the trace1 command can not be ?ished before leaving the low power mode. this is the case because bdm active mode can not be entered after cpu executed the stop instruction. however all bdm hardware commands except the background command are operational after tracing a stop or wait instruction and still being in stop or wait mode. if system stop mode is entered (all bus masters are in stop mode) no bdm command is operational. as soon as stop or wait mode is exited the cpu enters bdm active mode and the saved pc value points to the entry of the corresponding interrupt service routine. in case the handshake feature is enabled the corresponding ack pulse of the trace1 command will be discarded when tracing a stop or wait instruction. hence there is no ack pulse when bdm active mode is entered as part of the trace1 command after cpu exited from stop or wait mode. all valid commands sent during cpu being in stop or wait mode or after cpu exited from stop or wait mode will have an ack pulse. the handshake feature becomes disabled only when system stop mode has been reached. hence after a system stop mode the handshake feature must be enabled again by sending the ack_enable command. 7.4.11 serial communication time out the host initiates a host-to-target serial transmission by generating a falling edge on the bkgd pin. if bkgd is kept low for more than 128 target clock cycles, the target understands that a sync command was issued. in this case, the target will keep waiting for a rising edge on bkgd in order to answer the sync request pulse. if the rising edge is not detected, the target will keep waiting forever without any time-out limit. consider now the case where the host returns bkgd to logic one before 128 cycles. this is interpreted as a valid bit transmission, and not as a sync request. the target will keep waiting for another falling edge marking the start of a new bit. if, however, a new falling edge is not detected by the target within 512 clock cycles since the last falling edge, a time-out occurs and the current command is discarded without affecting memory or the operating mode of the mcu. this is referred to as a soft-reset. if a read command is issued but the data is not retrieved within 512 serial clock cycles, a soft-reset will occur causing the command to be disregarded. the data is not available for retrieval after the time-out has occurred. this is the expected behavior if the handshake protocol is not enabled. in order to allow the data to be retrieved even with a large clock frequency mismatch (between bdm and cpu) when the hardware
background debug module (s12sbdmv1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 311 handshake protocol is enabled, the time out between a read command and the data retrieval is disabled. therefore, the host could wait for more then 512 serial clock cycles and still be able to retrieve the data from an issued read command. however, once the handshake pulse (ack pulse) is issued, the time-out feature is re-activated, meaning that the target will time out after 512 clock cycles. therefore, the host needs to retrieve the data within a 512 serial clock cycles time frame after the ack pulse had been issued. after that period, the read command is discarded and the data is no longer available for retrieval. any negative edge in the bkgd pin after the time-out period is considered to be a new command or a sync request. note that whenever a partially issued command, or partially retrieved data, has occurred the time out in the serial communication is active. this means that if a time frame higher than 512 serial clock cycles is observed between two consecutive negative edges and the command being issued or data being retrieved is not complete, a soft-reset will occur causing the partially received command or data retrieved to be disregarded. the next negative edge in the bkgd pin, after a soft-reset has occurred, is considered by the target as the start of a new bdm command, or the start of a sync request pulse.
background debug module (s12sbdmv1) mc9s12g family reference manual, rev.1.23 312 freescale semiconductor
mc9s12g family reference manual, rev.1.23 freescale semiconductor 313 chapter 8 s12s debug module (s12sdbgv2) table 8-1. revision history 8.1 introduction the s12sdbg module provides an on-chip trace buffer with ?xible triggering capability to allow non-intrusive debug of application software. the s12sdbg module is optimized for s12scpu debugging. typically the s12sdbg module is used in conjunction with the s12sbdm module, whereby the user con?ures the s12sdbg module for a debugging session over the bdm interface. once con?ured the s12sdbg module is armed and the device leaves bdm returning control to the user program, which is then monitored by the s12sdbg module. alternatively the s12sdbg module can be con?ured over a serial interface using swi routines. 8.1.1 glossary of terms cof: change of flow. change in the program ?w due to a conditional branch, indexed jump or interrupt bdm: background debug mode s12sbdm: background debug module dug: device user guide, describing the features of the device into which the dbg is integrated word: 16-bit data entity data line: 20-bit data entity cpu: s12scpu module dbg: s12sdbg module por: power on reset revision number revision date sections affected summary of changes 02.08 09.may.2008 general spelling corrections. revision history format changed. 02.09 29.may.2008 8.4.5.4 added note for end aligned, purepc, rollover case. 02.10 27.sep.2012 general changed cross reference formats
s12s debug module (s12sdbgv2) mc9s12g family reference manual, rev.1.23 314 freescale semiconductor tag: tags can be attached to cpu opcodes as they enter the instruction pipe. if the tagged opcode reaches the execution stage a tag hit occurs. 8.1.2 overview the comparators monitor the bus activity of the cpu module. a match can initiate a state sequencer transition. on a transition to the final state, bus tracing is triggered and/or a breakpoint can be generated. independent of comparator matches a transition to final state with associated tracing and breakpoint can be triggered immediately by writing to the trig control bit. the trace buffer is visible through a 2-byte window in the register address map and can be read out using standard 16-bit word reads. tracing is disabled when the mcu system is secured. 8.1.3 features three comparators (a, b and c) comparators a compares the full address bus and full 16-bit data bus comparator a features a data bus mask register comparators b and c compare the full address bus only each comparator features selection of read or write access cycles comparator b allows selection of byte or word access cycles comparator matches can initiate state sequencer transitions three comparator modes simple address/data comparator match mode inside address range mode, addmin address addmax outside address range match mode, address < addmin or address > addmax two types of matches tagged ?this matches just before a speci? instruction begins execution force ?this is valid on the ?st instruction boundary after a match occurs two types of breakpoints cpu breakpoint entering bdm on breakpoint (bdm) cpu breakpoint executing swi on breakpoint (swi) trigger mode independent of comparators trig immediate software trigger four trace modes normal: change of ?w (cof) pc information is stored (see section 8.4.5.2.1, ?ormal mode ) for change of ?w de?ition. loop1: same as normal but inhibits consecutive duplicate source address entries detail: address and data for all cycles except free cycles and opcode fetches are stored compressed pure pc: all program counter addresses are stored
s12s debug module (s12sdbgv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 315 4-stage state sequencer for trace buffer control tracing session trigger linked to final state of state sequencer begin and end alignment of tracing to trigger 8.1.4 modes of operation the dbg module can be used in all mcu functional modes. during bdm hardware accesses and whilst the bdm module is active, cpu monitoring is disabled. when the cpu enters active bdm mode through a background command, the dbg module, if already armed, remains armed. the dbg module tracing is disabled if the mcu is secure, however, breakpoints can still be generated. 8.1.5 block diagram figure 8-1. debug module block diagram table 8-2. mode dependent restriction summary bdm enable bdm active mcu secure comparator matches enabled breakpoints possible tagging possible tracing possible x x 1 yes yes yes no 0 0 0 yes only swi yes yes 0 1 0 active bdm not possible when not enabled 1 0 0 yes yes yes yes 110 no no no no cpu bus trace buffer bus interface transition match0 state comparator b comparator c comparator a state sequencer match1 match2 trace read trace data (dbg read data bus) control secure breakpoint requests comparator match control trigger tag & match control logic tag s taghits state to cpu
s12s debug module (s12sdbgv2) mc9s12g family reference manual, rev.1.23 316 freescale semiconductor 8.2 external signal description there are no external signals associated with this module. 8.3 memory map and registers 8.3.1 module memory map a summary of the registers associated with the dbg sub-block is shown in figure 8-2 . detailed descriptions of the registers and bits are given in the subsections that follow. address name bit 7 6 5 4 3 2 1 bit 0 0x0020 dbgc1 r arm 00 bdm dbgbrk 0 comrv w trig 0x0021 dbgsr r 1 tbf 0 0 0 0 ssf2 ssf1 ssf0 w 0x0022 dbgtcr r0 tsource 00 trcmod 0 talign w 0x0023 dbgc2 r000000 abcm w 0x0024 dbgtbh r bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 w 0x0025 dbgtbl r bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 w 0x0026 dbgcnt r 1 tbf 0 cnt w 0x0027 dbgscrx r0000 sc3 sc2 sc1 sc0 w 0x0027 dbgmfr r 0 0 0 0 0 mc2 mc1 mc0 w 2 0x0028 dbgactl r sze sz tag brk rw rwe ndb compe w 3 0x0028 dbgbctl r sze sz tag brk rw rwe 0 compe w 4 0x0028 dbgcctl r0 0 tag brk rw rwe 0 compe w 0x0029 dbgxah r000000 bit 17 bit 16 w 0x002a dbgxam r bit 15 14 13 12 11 10 9 bit 8 w 0x002b dbgxal r bit 7 6 5 4 3 2 1 bit 0 w figure 8-2. quick reference to dbg registers
s12s debug module (s12sdbgv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 317 8.3.2 register descriptions this section consists of the dbg control and trace buffer register descriptions in address order. each comparator has a bank of registers that are visible through an 8-byte window between 0x0028 and 0x002f in the dbg module register address map. when arm is set in dbgc1, the only bits in the dbg module registers that can be written are arm, trig, and comrv[1:0]. 8.3.2.1 debug control register 1 (dbgc1) read: anytime write: bits 7, 1, 0 anytime bit 6 can be written anytime but always reads back as 0. bits 4:3 anytime dbg is not armed. note when disarming the dbg by clearing arm with software, the contents of bits[4:3] are not affected by the write, since up until the write operation, arm = 1 preventing these bits from being written. these bits must be cleared using a second write if required. 0x002c dbgadh r bit 15 14 13 12 11 10 9 bit 8 w 0x002d dbgadl r bit 7 6 5 4 3 2 1 bit 0 w 0x002e dbgadhm r bit 15 14 13 12 11 10 9 bit 8 w 0x002f dbgadlm r bit 7 6 5 4 3 2 1 bit 0 w 1 this bit is visible at dbgcnt[7] and dbgsr[7] 2 this represents the contents if the comparator a control register is blended into this address. 3 this represents the contents if the comparator b control register is blended into this address 4 this represents the contents if the comparator c control register is blended into this address address: 0x0020 76543210 r arm 00 bdm dbgbrk 0 comrv w trig reset 00000000 = unimplemented or reserved figure 8-3. debug control register (dbgc1) address name bit 7 6 5 4 3 2 1 bit 0 figure 8-2. quick reference to dbg registers
s12s debug module (s12sdbgv2) mc9s12g family reference manual, rev.1.23 318 freescale semiconductor 8.3.2.2 debug status register (dbgsr) table 8-3. dbgc1 field descriptions field description 7 arm arm bit ?the arm bit controls whether the dbg module is armed. this bit can be set and cleared by user software and is automatically cleared on completion of a debug session, or if a breakpoint is generated with tracing not enabled. on setting this bit the state sequencer enters state1. 0 debugger disarmed 1 debugger armed 6 trig immediate trigger request bit this bit when written to 1 requests an immediate trigger independent of state sequencer status. when tracing is complete a forced breakpoint may be generated depending upon dbgbrk and bdm bit settings. this bit always reads back a 0. writing a 0 to this bit has no effect. if the dbgtcr_tsource bit is clear no tracing is carried out. if tracing has already commenced using begin trigger alignment, it continues until the end of the tracing session as de?ed by the talign bit, thus trig has no affect. in secure mode tracing is disabled and writing to this bit cannot initiate a tracing session. the session is ended by setting trig and arm simultaneously. 0 do not trigger until the state sequencer enters the final state. 1 trigger immediately 4 bdm background debug mode enable this bit determines if a breakpoint causes the system to enter background debug mode (bdm) or initiate a software interrupt (swi). if this bit is set but the bdm is not enabled by the enbdm bit in the bdm module, then breakpoints default to swi. 0 breakpoint to software interrupt if bdm inactive. otherwise no breakpoint. 1 breakpoint to bdm, if bdm enabled. otherwise breakpoint to swi 3 dbgbrk s12sdbg breakpoint enable bit the dbgbrk bit controls whether the debugger will request a breakpoint on reaching the state sequencer final state. if tracing is enabled, the breakpoint is generated on completion of the tracing session. if tracing is not enabled, the breakpoint is generated immediately. 0 no breakpoint generated 1 breakpoint generated 1? comrv comparator register visibility bits these bits determine which bank of comparator register is visible in the 8-byte window of the s12sdbg module address map, located between 0x0028 to 0x002f. furthermore these bits determine which register is visible at the address 0x0027. see table 8-4 . table 8-4. comrv encoding comrv visible comparator visible register at 0x0027 00 comparator a dbgscr1 01 comparator b dbgscr2 10 comparator c dbgscr3 11 none dbgmfr
s12s debug module (s12sdbgv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 319 read: anytime write: never 8.3.2.3 debug trace control register (dbgtcr) address: 0x0021 76543210 r tbf 0 0 0 0 ssf2 ssf1 ssf0 w reset por 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 = unimplemented or reserved figure 8-4. debug status register (dbgsr) table 8-5. dbgsr field descriptions field description 7 tbf trace buffer full the tbf bit indicates that the trace buffer has stored 64 or more lines of data since it was last armed. if this bit is set, then all 64 lines will be valid data, regardless of the value of dbgcnt bits. the tbf bit is cleared when arm in dbgc1 is written to a one. the tbf is cleared by the power on reset initialization. other system generated resets have no affect on this bit this bit is also visible at dbgcnt[7] 2? ssf[2:0] state sequencer flag bits the ssf bits indicate in which state the state sequencer is currently in. during a debug session on each transition to a new state these bits are updated. if the debug session is ended by software clearing the arm bit, then these bits retain their value to re?ct the last state of the state sequencer before disarming. if a debug session is ended by an internal event, then the state sequencer returns to state0 and these bits are cleared to indicate that state0 was entered during the session. on arming the module the state sequencer enters state1 and these bits are forced to ssf[2:0] = 001. see table 8-6 . table 8-6. ssf[2:0] ?state sequence flag bit encoding ssf[2:0] current state 000 state0 (disarmed) 001 state1 010 state2 011 state3 100 final state 101,110,111 reserved address: 0x0022 76543210 r0 tsource 00 trcmod 0 talign w reset 00000000 figure 8-5. debug trace control register (dbgtcr)
s12s debug module (s12sdbgv2) mc9s12g family reference manual, rev.1.23 320 freescale semiconductor read: anytime write: bit 6 only when dbg is neither secure nor armed.bits 3,2,0 anytime the module is disarmed. 8.3.2.4 debug control register2 (dbgc2) read: anytime write: anytime the module is disarmed. this register con?ures the comparators for range matching. table 8-7. dbgtcr field descriptions field description 6 tsource trace source control bit the tsource bit enables a tracing session given a trigger condition. if the mcu system is secured, this bit cannot be set and tracing is inhibited. this bit must be set to read the trace buffer. 0 debug session without tracing requested 1 debug session with tracing requested 3? trcmod trace mode bits see section 8.4.5.2, ?race modes for detailed trace mode descriptions. in normal mode, change of ?w information is stored. in loop1 mode, change of ?w information is stored but redundant entries into trace memory are inhibited. in detail mode, address and data for all memory and register accesses is stored. in compressed pure pc mode the program counter value for each instruction executed is stored. see table 8-8 . 0 talign trigger align bit this bit controls whether the trigger is aligned to the beginning or end of a tracing session. 0 trigger at end of stored data 1 trigger before storing data table 8-8. trcmod trace mode bit encoding trcmod description 00 normal 01 loop1 10 detail 11 compressed pure pc address: 0x0023 76543210 r000000 abcm w reset 00000000 = unimplemented or reserved figure 8-6. debug control register2 (dbgc2) table 8-9. dbgc2 field descriptions field description 1? abcm[1:0] a and b comparator match control ?these bits determine the a and b comparator match mapping as described in table 8-10 .
s12s debug module (s12sdbgv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 321 8.3.2.5 debug trace buffer register (dbgtbh:dbgtbl) read: only when unlocked and unsecured and not armed and tsource set. write: aligned word writes when disarmed unlock the trace buffer for reading but do not affect trace buffer contents. 8.3.2.6 debug count register (dbgcnt) table 8-10. abcm encoding abcm description 00 match0 mapped to comparator a match: match1 mapped to comparator b match. 01 match 0 mapped to comparator a/b inside range: match1 disabled. 10 match 0 mapped to comparator a/b outside range: match1 disabled. 11 reserved 1 1 currently defaults to comparator a, comparator b disabled address: 0x0024, 0x0025 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 w porxxxxxxxxxxxxxxxx other resets figure 8-7. debug trace buffer register (dbgtb) table 8-11. dbgtb field descriptions field description 15? bit[15:0] trace buffer data bits the trace buffer register is a window through which the 20-bit wide data lines of the trace buffer may be read 16 bits at a time. each valid read of dbgtb increments an internal trace buffer pointer which points to the next address to be read. when the arm bit is set the trace buffer is locked to prevent reading. the trace buffer can only be unlocked for reading by writing to dbgtb with an aligned word write when the module is disarmed. the dbgtb register can be read only as an aligned word, any byte reads or misaligned access of these registers return 0 and do not cause the trace buffer pointer to increment to the next trace buffer address. similarly reads while the debugger is armed or with the tsource bit clear, return 0 and do not affect the trace buffer pointer. the por state is unde?ed. other resets do not affect the trace buffer contents. address: 0x0026 76543210 r tbf 0 cnt w reset por 0 0 0 0 0 0 0 0 = unimplemented or reserved figure 8-8. debug count register (dbgcnt)
s12s debug module (s12sdbgv2) mc9s12g family reference manual, rev.1.23 322 freescale semiconductor read: anytime write: never 8.3.2.7 debug state control registers there is a dedicated control register for each of the state sequencer states 1 to 3 that determines if transitions from that state are allowed, depending upon comparator matches or tag hits, and de?es the next state for the state sequencer following a match. the three debug state control registers are located at the same address in the register address map (0x0027). each register can be accessed using the comrv bits in dbgc1 to blend in the required register. the comrv = 11 value blends in the match ?g register (dbgmfr). table 8-12. dbgcnt field descriptions field description 7 tbf trace buffer full the tbf bit indicates that the trace buffer has stored 64 or more lines of data since it was last armed. if this bit is set, then all 64 lines will be valid data, regardless of the value of dbgcnt bits. the tbf bit is cleared when arm in dbgc1 is written to a one. the tbf is cleared by the power on reset initialization. other system generated resets have no affect on this bit this bit is also visible at dbgsr[7] 5? cnt[5:0] count value ?the cnt bits indicate the number of valid data 20-bit data lines stored in the trace buffer. table 8-13 shows the correlation between the cnt bits and the number of valid data lines in the trace buffer. when the cnt rolls over to zero, the tbf bit in dbgsr is set and incrementing of cnt will continue in end-trigger mode. the dbgcnt register is cleared when arm in dbgc1 is written to a one. the dbgcnt register is cleared by power-on-reset initialization but is not cleared by other system resets. thus should a reset occur during a debug session, the dbgcnt register still indicates after the reset, the number of valid trace buffer entries stored before the reset occurred. the dbgcnt register is not decremented when reading from the trace buffer. table 8-13. cnt decoding table tbf cnt[5:0] description 0 000000 no data valid 0 000001 000010 000100 000110 .. 111111 1 line valid 2 lines valid 4 lines valid 6 lines valid .. 63 lines valid 1 000000 64 lines valid; if using begin trigger alignment, arm bit will be cleared and the tracing session ends. 1 000001 .. .. 111110 64 lines valid, oldest data has been overwritten by most recent data table 8-14. state control register access encoding comrv visible state control register 00 dbgscr1
s12s debug module (s12sdbgv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 323 8.3.2.7.1 debug state control register 1 (dbgscr1) read: if comrv[1:0] = 00 write: if comrv[1:0] = 00 and dbg is not armed. this register is visible at 0x0027 only with comrv[1:0] = 00. the state control register 1 selects the targeted next state whilst in state1. the matches refer to the match channels of the comparator match control logic as depicted in figure 8-1 and described in section 8.3.2.8.1, ?ebug comparator control register (dbgxctl) . comparators must be enabled by setting the comparator enable bit in the associated dbgxctl control register. 01 dbgscr2 10 dbgscr3 11 dbgmfr address: 0x0027 76543210 r0000 sc3 sc2 sc1 sc0 w reset 00000000 = unimplemented or reserved figure 8-9. debug state control register 1 (dbgscr1) table 8-15. dbgscr1 field descriptions field description 3? sc[3:0] these bits select the targeted next state whilst in state1, based upon the match event. table 8-16. state1 sequencer next state selection sc[3:0] description (unspeci?d matches have no effect) 0000 any match to final state 0001 match1 to state3 0010 match2 to state2 0011 match1 to state2 0100 match0 to state2....... match1 to state3 0101 match1 to state3.........match0 to final state 0110 match0 to state2....... match2 to state3 0111 either match0 or match1 to state2 1000 reserved 1001 match0 to state3 table 8-14. state control register access encoding comrv visible state control register
s12s debug module (s12sdbgv2) mc9s12g family reference manual, rev.1.23 324 freescale semiconductor the priorities described in table 8-36 dictate that in the case of simultaneous matches, a match leading to ?al state has priority followed by the match on the lower channel number (0,1,2). thus with sc[3:0]=1101 a simultaneous match0/match1 transitions to final state. 8.3.2.7.2 debug state control register 2 (dbgscr2) read: if comrv[1:0] = 01 write: if comrv[1:0] = 01 and dbg is not armed. this register is visible at 0x0027 only with comrv[1:0] = 01. the state control register 2 selects the targeted next state whilst in state2. the matches refer to the match channels of the comparator match control logic as depicted in figure 8-1 and described in section 8.3.2.8.1, ?ebug comparator control register (dbgxctl) . comparators must be enabled by setting the comparator enable bit in the associated dbgxctl control register. 1010 reserved 1011 reserved 1100 reserved 1101 either match0 or match2 to final state........match1 to state2 1110 reserved 1111 reserved address: 0x0027 76543210 r0000 sc3 sc2 sc1 sc0 w reset 00000000 = unimplemented or reserved figure 8-10. debug state control register 2 (dbgscr2) table 8-17. dbgscr2 field descriptions field description 3? sc[3:0] these bits select the targeted next state whilst in state2, based upon the match event. table 8-18. state2 ?equencer next state selection sc[3:0] description (unspeci?d matches have no effect) 0000 match0 to state1....... match2 to state3. 0001 match1 to state3 0010 match2 to state3 0011 match1 to state3....... match0 final state 0100 match1 to state1....... match2 to state3. table 8-16. state1 sequencer next state selection sc[3:0] description (unspeci?d matches have no effect)
s12s debug module (s12sdbgv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 325 the priorities described in table 8-36 dictate that in the case of simultaneous matches, a match leading to ?al state has priority followed by the match on the lower channel number (0,1,2). 8.3.2.7.3 debug state control register 3 (dbgscr3) read: if comrv[1:0] = 10 write: if comrv[1:0] = 10 and dbg is not armed. this register is visible at 0x0027 only with comrv[1:0] = 10. the state control register three selects the targeted next state whilst in state3. the matches refer to the match channels of the comparator match control logic as depicted in figure 8-1 and described in section 8.3.2.8.1, ?ebug comparator control register (dbgxctl) . comparators must be enabled by setting the comparator enable bit in the associated dbgxctl control register. 0101 match2 to final state 0110 match2 to state1..... match0 to final state 0111 either match0 or match1 to final state 1000 reserved 1001 reserved 1010 reserved 1011 reserved 1100 either match0 or match1 to final state........match2 to state3 1101 reserved 1110 reserved 1111 either match0 or match1 to final state........match2 to state1 address: 0x0027 76543210 r0000 sc3 sc2 sc1 sc0 w reset 00000000 = unimplemented or reserved figure 8-11. debug state control register 3 (dbgscr3) table 8-19. dbgscr3 field descriptions field description 3? sc[3:0] these bits select the targeted next state whilst in state3, based upon the match event. table 8-20. state3 ?sequencer next state selection sc[3:0] description (unspeci?d matches have no effect) 0000 match0 to state1 table 8-18. state2 ?equencer next state selection sc[3:0] description (unspeci?d matches have no effect)
s12s debug module (s12sdbgv2) mc9s12g family reference manual, rev.1.23 326 freescale semiconductor the priorities described in table 8-36 dictate that in the case of simultaneous matches, a match leading to ?al state has priority followed by the match on the lower channel number (0,1,2). 8.3.2.7.4 debug match flag register (dbgmfr) read: if comrv[1:0] = 11 write: never dbgmfr is visible at 0x0027 only with comrv[1:0] = 11. it features 3 ?g bits each mapped directly to a channel. should a match occur on the channel during the debug session, then the corresponding ?g is set and remains set until the next time the module is armed by writing to the arm bit. thus the contents are retained after a debug session for evaluation purposes. these ?gs cannot be cleared by software, they are cleared only when arming the module. a set ?g does not inhibit the setting of other ?gs. once a ?g is set, further comparator matches on the same channel in the same session have no affect on that ?g. 8.3.2.8 comparator register descriptions each comparator has a bank of registers that are visible through an 8-byte window in the dbg module register address map. comparator a consists of 8 register bytes (3 address bus compare registers, two data bus compare registers, two data bus mask registers and a control register). comparator b consists of four 0001 match2 to state2........ match1 to final state 0010 match0 to final state....... match1 to state1 0011 match1 to final state....... match2 to state1 0100 match1 to state2 0101 match1 to final state 0110 match2 to state2........ match0 to final state 0111 match0 to final state 1000 reserved 1001 reserved 1010 either match1 or match2 to state1....... match0 to final state 1011 reserved 1100 reserved 1101 either match1 or match2 to final state....... match0 to state1 1110 match0 to state2....... match2 to final state 1111 reserved address: 0x0027 76543210 r00000mc2mc1mc0 w reset 00000000 = unimplemented or reserved figure 8-12. debug match flag register (dbgmfr) table 8-20. state3 ?sequencer next state selection sc[3:0] description (unspeci?d matches have no effect)
s12s debug module (s12sdbgv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 327 register bytes (three address bus compare registers and a control register). comparator c consists of four register bytes (three address bus compare registers and a control register). each set of comparator registers can be accessed using the comrv bits in the dbgc1 register. unimplemented registers (e.g. comparator b data bus and data bus masking) read as zero and cannot be written. the control register for comparator b differs from those of comparators a and c. 8.3.2.8.1 debug comparator control register (dbgxctl) the contents of this register bits 7 and 6 differ depending upon which comparator registers are visible in the 8-byte window of the dbg module register address map. table 8-21. comparator register layout 0x0028 control read/write comparators a,b and c 0x0029 address high read/write comparators a,b and c 0x002a address medium read/write comparators a,b and c 0x002b address low read/write comparators a,b and c 0x002c data high comparator read/write comparator a only 0x002d data low comparator read/write comparator a only 0x002e data high mask read/write comparator a only 0x002f data low mask read/write comparator a only address: 0x0028 76543210 r sze sz tag brk rw rwe ndb compe w reset 00000000 = unimplemented or reserved figure 8-13. debug comparator control register dbgactl (comparator a) address: 0x0028 76543210 r sze sz tag brk rw rwe 0 compe w reset 00000000 = unimplemented or reserved figure 8-14. debug comparator control register dbgbctl (comparator b) address: 0x0028 76543210 r0 0 tag brk rw rwe 0 compe w reset 00000000 = unimplemented or reserved figure 8-15. debug comparator control register dbgcctl (comparator c)
s12s debug module (s12sdbgv2) mc9s12g family reference manual, rev.1.23 328 freescale semiconductor read: dbgactl if comrv[1:0] = 00 dbgbctl if comrv[1:0] = 01 dbgcctl if comrv[1:0] = 10 write: dbgactl if comrv[1:0] = 00 and dbg not armed dbgbctl if comrv[1:0] = 01 and dbg not armed dbgcctl if comrv[1:0] = 10 and dbg not armed table 8-23 shows the effect for rwe and rw on the comparison conditions. these bits are ignored if the corresponding tag bit is set since the match occurs based on the tagged opcode reaching the execution stage of the instruction queue. table 8-22. dbgxctl field descriptions field description 7 sze (comparators a and b) size comparator enable bit ?the sze bit controls whether access size comparison is enabled for the associated comparator. this bit is ignored if the tag bit in the same register is set. 0 word/byte access size is not used in comparison 1 word/byte access size is used in comparison 6 sz (comparators a and b) size comparator value bit ?the sz bit selects either word or byte access size in comparison for the associated comparator. this bit is ignored if the sze bit is cleared or if the tag bit in the same register is set. 0 word access size is compared 1 byte access size is compared 5 tag tag select ?this bit controls whether the comparator match has immediate effect, causing an immediate state sequencer transition or tag the opcode at the matched address. tagged opcodes trigger only if they reach the execution stage of the instruction queue. 0 allow state sequencer transition immediately on match 1 on match, tag the opcode. if the opcode is about to be executed allow a state sequencer transition 4 brk break this bit controls whether a comparator match terminates a debug session immediately, independent of state sequencer state. to generate an immediate breakpoint the module breakpoints must be enabled using the dbgc1 bit dbgbrk. 0 the debug session termination is dependent upon the state sequencer and trigger conditions. 1 a match on this channel terminates the debug session immediately; breakpoints if active are generated, tracing, if active, is terminated and the module disarmed. 3 rw read/write comparator value bit the rw bit controls whether read or write is used in compare for the associated comparator. the rw bit is not used if rwe = 0. this bit is ignored if the tag bit in the same register is set. 0 write cycle is matched1read cycle is matched 2 rwe read/write enable bit ?the rwe bit controls whether read or write comparison is enabled for the associated comparator.this bit is ignored if the tag bit in the same register is set 0 read/write is not used in comparison 1 read/write is used in comparison 1 ndb (comparator a) not data bus the ndb bit controls whether the match occurs when the data bus matches the comparator register value or when the data bus differs from the register value. this bit is ignored if the tag bit in the same register is set. this bit is only available for comparator a. 0 match on data bus equivalence to comparator register contents 1 match on data bus difference to comparator register contents 0 compe determines if comparator is enabled 0 the comparator is not enabled 1 the comparator is enabled
s12s debug module (s12sdbgv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 329 8.3.2.8.2 debug comparator address high register (dbgxah) the dbgc1_comrv bits determine which comparator address registers are visible in the 8-byte window from 0x0028 to 0x002f as shown in section table 8-24., ?omparator address register visibility table 8-24. comparator address register visibility read: anytime. see table 8-24 for visible register encoding. write: if dbg not armed. see table 8-24 for visible register encoding. table 8-23. read or write comparison logic table rwe bit rw bit rw signal comment 0 x 0 rw not used in comparison 0 x 1 rw not used in comparison 1 0 0 write data bus 1 0 1 no match 1 1 0 no match 1 1 1 read data bus address: 0x0029 76543210 r000000 bit 17 bit 16 w reset 00000000 = unimplemented or reserved figure 8-16. debug comparator address high register (dbgxah) comrv visible comparator 00 dbgaah, dbgaam, dbgaal 01 dbgbah, dbgbam, dbgbal 10 dbgcah, dbgcam, dbgcal 11 none table 8-25. dbgxah field descriptions field description 1? bit[17:16] comparator address high compare bits the comparator address high compare bits control whether the selected comparator compares the address bus bits [17:16] to a logic one or logic zero. 0 compare corresponding address bit to a logic zero 1 compare corresponding address bit to a logic one
s12s debug module (s12sdbgv2) mc9s12g family reference manual, rev.1.23 330 freescale semiconductor 8.3.2.8.3 debug comparator address mid register (dbgxam) read: anytime. see table 8-24 for visible register encoding. write: if dbg not armed. see table 8-24 for visible register encoding. 8.3.2.8.4 debug comparator address low register (dbgxal) read: anytime. see table 8-24 for visible register encoding. write: if dbg not armed. see table 8-24 for visible register encoding. address: 0x002a 76543210 r bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 w reset 00000000 figure 8-17. debug comparator address mid register (dbgxam) table 8-26. dbgxam field descriptions field description 7? bit[15:8] comparator address mid compare bits ?the comparator address mid compare bits control whether the selected comparator compares the address bus bits [15:8] to a logic one or logic zero. 0 compare corresponding address bit to a logic zero 1 compare corresponding address bit to a logic one address: 0x002b 76543210 r bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 w reset 00000000 figure 8-18. debug comparator address low register (dbgxal) table 8-27. dbgxal field descriptions field description 7? bits[7:0] comparator address low compare bits ?the comparator address low compare bits control whether the selected comparator compares the address bus bits [7:0] to a logic one or logic zero. 0 compare corresponding address bit to a logic zero 1 compare corresponding address bit to a logic one
s12s debug module (s12sdbgv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 331 8.3.2.8.5 debug comparator data high register (dbgadh) read: if comrv[1:0] = 00 write: if comrv[1:0] = 00 and dbg not armed. 8.3.2.8.6 debug comparator data low register (dbgadl) read: if comrv[1:0] = 00 write: if comrv[1:0] = 00 and dbg not armed. address: 0x002c 76543210 r bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 w reset 00000000 figure 8-19. debug comparator data high register (dbgadh) table 8-28. dbgadh field descriptions field description 7? bits[15:8] comparator data high compare bits the comparator data high compare bits control whether the selected comparator compares the data bus bits [15:8] to a logic one or logic zero. the comparator data compare bits are only used in comparison if the corresponding data mask bit is logic 1. this register is available only for comparator a. data bus comparisons are only performed if the tag bit in dbgactl is clear. 0 compare corresponding data bit to a logic zero 1 compare corresponding data bit to a logic one address: 0x002d 76543210 r bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 w reset 00000000 figure 8-20. debug comparator data low register (dbgadl) table 8-29. dbgadl field descriptions field description 7? bits[7:0] comparator data low compare bits the comparator data low compare bits control whether the selected comparator compares the data bus bits [7:0] to a logic one or logic zero. the comparator data compare bits are only used in comparison if the corresponding data mask bit is logic 1. this register is available only for comparator a. data bus comparisons are only performed if the tag bit in dbgactl is clear 0 compare corresponding data bit to a logic zero 1 compare corresponding data bit to a logic one
s12s debug module (s12sdbgv2) mc9s12g family reference manual, rev.1.23 332 freescale semiconductor 8.3.2.8.7 debug comparator data high mask register (dbgadhm) read: if comrv[1:0] = 00 write: if comrv[1:0] = 00 and dbg not armed. 8.3.2.8.8 debug comparator data low mask register (dbgadlm) read: if comrv[1:0] = 00 write: if comrv[1:0] = 00 and dbg not armed. 8.4 functional description this section provides a complete functional description of the dbg module. if the part is in secure mode, the dbg module can generate breakpoints but tracing is not possible. address: 0x002e 76543210 r bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 w reset 00000000 figure 8-21. debug comparator data high mask register (dbgadhm) table 8-30. dbgadhm field descriptions field description 7? bits[15:8] comparator data high mask bits ?the comparator data high mask bits control whether the selected comparator compares the data bus bits [15:8] to the corresponding comparator data compare bits. data bus comparisons are only performed if the tag bit in dbgactl is clear 0 do not compare corresponding data bit any value of corresponding data bit allows match. 1 compare corresponding data bit address: 0x002f 76543210 r bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 w reset 00000000 figure 8-22. debug comparator data low mask register (dbgadlm) table 8-31. dbgadlm field descriptions field description 7? bits[7:0] comparator data low mask bits ?the comparator data low mask bits control whether the selected comparator compares the data bus bits [7:0] to the corresponding comparator data compare bits. data bus comparisons are only performed if the tag bit in dbgactl is clear 0 do not compare corresponding data bit. any value of corresponding data bit allows match 1 compare corresponding data bit
s12s debug module (s12sdbgv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 333 8.4.1 s12sdbg operation arming the dbg module by setting arm in dbgc1 allows triggering the state sequencer, storing of data in the trace buffer and generation of breakpoints to the cpu. the dbg module is made up of four main blocks, the comparators, control logic, the state sequencer, and the trace buffer. the comparators monitor the bus activity of the cpu. all comparators can be con?ured to monitor address bus activity. comparator a can also be con?ured to monitor databus activity and mask out individual data bus bits during a compare. comparators can be con?ured to use r/w and word/byte access quali?ation in the comparison. a match with a comparator register value can initiate a state sequencer transition to another state (see figure 8-24 ). either forced or tagged matches are possible. using a forced match, a state sequencer transition can occur immediately on a successful match of system busses and comparator registers. whilst tagging, at a comparator match, the instruction opcode is tagged and only if the instruction reaches the execution stage of the instruction queue can a state sequencer transition occur. in the case of a transition to final state, bus tracing is triggered and/or a breakpoint can be generated. a state sequencer transition to ?al state (with associated breakpoint, if enabled) can be initiated by writing to the trig bit in the dbgc1 control register. the trace buffer is visible through a 2-byte window in the register address map and must be read out using standard 16-bit word reads. figure 8-23. dbg overview 8.4.2 comparator modes the dbg contains three comparators, a, b and c. each comparator compares the system address bus with the address stored in dbgxah, dbgxam, and dbgxal. furthermore, comparator a also compares the data buses to the data stored in dbgadh, dbgadl and allows masking of individual data bus bits. cpu bus trace buffer bus interface transition match0 state comparator b comparator c comparator a state sequencer match1 match2 trace read trace data (dbg read data bus) control secure breakpoint requests comparator match control trigger tag & match control logic tag s taghits state to cpu
s12s debug module (s12sdbgv2) mc9s12g family reference manual, rev.1.23 334 freescale semiconductor all comparators are disabled in bdm and during bdm accesses. the comparator match control logic (see figure 8-23 ) con?ures comparators to monitor the buses for an exact address or an address range, whereby either an access inside or outside the speci?d range generates a match condition. the comparator con?uration is controlled by the control register contents and the range control by the dbgc2 contents. a match can initiate a transition to another state sequencer state (see section 8.4.4, ?tate sequence control ). the comparator control register also allows the type of access to be included in the comparison through the use of the rwe, rw, sze, and sz bits. the rwe bit controls whether read or write comparison is enabled for the associated comparator and the rw bit selects either a read or write access for a valid match. similarly the sze and sz bits allow the size of access (word or byte) to be considered in the compare. only comparators a and b feature sze and sz. the tag bit in each comparator control register is used to determine the match condition. by setting tag, the comparator quali?s a match with the output of opcode tracking logic and a state sequencer transition occurs when the tagged instruction reaches the cpu execution stage. whilst tagging the rw, rwe, sze, and sz bits and the comparator data registers are ignored; the comparator address register must be loaded with the exact opcode address. if the tag bit is clear (forced type match) a comparator match is generated when the selected address appears on the system address bus. if the selected address is an opcode address, the match is generated when the opcode is fetched from the memory, which precedes the instruction execution by an inde?ite number of cycles due to instruction pipelining. for a comparator match of an opcode at an odd address when tag = 0, the corresponding even address must be contained in the comparator register. thus for an opcode at odd address (n), the comparator register must contain address (n?). once a successful comparator match has occurred, the condition that caused the original match is not veri?d again on subsequent matches. thus if a particular data value is veri?d at a given address, this address may not still contain that data value when a subsequent match occurs. match[0, 1, 2] map directly to comparators [a, b, c] respectively, except in range modes (see section 8.3.2.4, ?ebug control register2 (dbgc2) ). comparator channel priority rules are described in the priority section ( section 8.4.3.4, ?hannel priorities) . 8.4.2.1 single address comparator match with range comparisons disabled, the match condition is an exact equivalence of address bus with the value stored in the comparator address registers. further quali?ation of the type of access (r/w, word/byte) and databus contents is possible, depending on comparator channel. 8.4.2.1.1 comparator c comparator c offers only address and direction (r/w) comparison. the exact address is compared, thus with the comparator address register loaded with address (n) a word access of address (n?) also accesses (n) but does not cause a match.
s12s debug module (s12sdbgv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 335 8.4.2.1.2 comparator b comparator b offers address, direction (r/w) and access size (word/byte) comparison. if the sze bit is set the access size (word or byte) is compared with the sz bit value such that only the speci?d size of access causes a match. thus if con?ured for a byte access of a particular address, a word access covering the same address does not lead to match. assuming the access direction is not quali?d (rwe=0), for simplicity, the size access considerations are shown in table 8-33 . access direction can also be used to qualify a match for comparator b in the same way as described for comparator c in table 8-32 . 8.4.2.1.3 comparator a comparator a offers address, direction (r/w), access size (word/byte) and data bus comparison. table 8-34 lists access considerations with data bus comparison. on word accesses the data byte of the lower address is mapped to dbgadh. access direction can also be used to qualify a match for comparator a in the same way as described for comparator c in table 8-32 . table 8-34. comparator a matches when accessing addr[n] table 8-32. comparator c access considerations condition for valid match comp c address rwe rw examples read and write accesses of addr[n] addr[n] 1 1 a word access of addr[n-1] also accesses addr[n] but does not generate a match. the comparator address register must contain the exact address from the code. 0 x ldaa addr[n] staa #$byte addr[n] write accesses of addr[n] addr[n] 1 0 staa #$byte addr[n] read accesses of addr[n] addr[n] 1 1 ldaa #$byte addr[n] table 8-33. comparator b access size considerations condition for valid match comp b address rwe sze sz8 examples word and byte accesses of addr[n] addr[n] 1 1 a word access of addr[n-1] also accesses addr[n] but does not generate a match. the comparator address register must contain the exact address from the code. 0 0 x movb #$byte addr[n] movw #$word addr[n] word accesses of addr[n] only addr[n] 0 1 0 movw #$word addr[n] ldd addr[n] byte accesses of addr[n] only addr[n] 0 1 1 movb #$byte addr[n] ldab addr[n] sze sz dbgadhm, dbgadlm access dh=dbgadh, dl=dbgadl comment 0 x $0000 byte word no databus comparison
s12s debug module (s12sdbgv2) mc9s12g family reference manual, rev.1.23 336 freescale semiconductor 8.4.2.1.4 comparator a data bus comparison ndb dependency comparator a features an ndb control bit, which allows data bus comparators to be con?ured to either trigger on equivalence or trigger on difference. this allows monitoring of a difference in the contents of an address location from an expected value. when matching on an equivalence (ndb=0), each individual data bus bit position can be masked out by clearing the corresponding mask bit (dbgadhm/dbgadlm) so that it is ignored in the comparison. a match occurs when all data bus bits with corresponding mask bits set are equivalent. if all mask register bits are clear, then a match is based on the address bus only, the data bus is ignored. when matching on a difference, mask bits can be cleared to ignore bit positions. a match occurs when any data bus bit with corresponding mask bit set is different. clearing all mask bits, causes all bits to be ignored and prevents a match because no difference can be detected. in this case address bus equivalence does not cause a match. 8.4.2.2 range comparisons using the ab comparator pair for a range comparison, the data bus can also be used for quali?ation by using the comparator a data registers. furthermore the dbgactl rw and rwe bits can be used to qualify the range comparison on either a read or a write access. the corresponding dbgbctl bits are ignored. the sze and sz control bits are ignored in range mode. the comparator a tag bit is used to tag 0 x $ff00 byte, data(addr[n])=dh word, data(addr[n])=dh, data(addr[n+1])=x match data( addr[n]) 0 x $00ff word, data(addr[n])=x, data(addr[n+1])=dl match data( addr[n+1]) 0 x $00ff byte, data(addr[n])=x, data(addr[n+1])=dl possible unintended match 0 x $ffff word, data(addr[n])=dh, data(addr[n+1])=dl match data( addr[n], addr[n+1]) 0 x $ffff byte, data(addr[n])=dh, data(addr[n+1])=dl possible unintended match 1 0 $0000 word no databus comparison 1 0 $00ff word, data(addr[n])=x, data(addr[n+1])=dl match only data at addr[n+1] 1 0 $ff00 word, data(addr[n])=dh, data(addr[n+1])=x match only data at addr[n] 1 0 $ffff word, data(addr[n])=dh, data(addr[n+1])=dl match data at addr[n] & addr[n+1] 1 1 $0000 byte no databus comparison 1 1 $ff00 byte, data(addr[n])=dh match data at addr[n] table 8-35. ndb and mask bit dependency ndb dbgadhm[n] / dbgadlm[n] comment 0 0 do not compare data bus bit. 0 1 compare data bus bit. match on equivalence. 1 0 do not compare data bus bit. 1 1 compare data bus bit. match on difference. sze sz dbgadhm, dbgadlm access dh=dbgadh, dl=dbgadl comment
s12s debug module (s12sdbgv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 337 range comparisons. the comparator b tag bit is ignored in range modes. in order for a range comparison using comparators a and b, both compea and compeb must be set; to disable range comparisons both must be cleared. the comparator a brk bit is used to for the ab range, the comparator b brk bit is ignored in range mode. when con?ured for range comparisons and tagging, the ranges are accurate only to word boundaries. 8.4.2.2.1 inside range (compa_addr address compb_addr) in the inside range comparator mode, comparator pair a and b can be con?ured for range comparisons. this con?uration depends upon the control register (dbgc2). the match condition requires that a valid match for both comparators happens on the same bus cycle. a match condition on only one comparator is not valid. an aligned word access which straddles the range boundary is valid only if the aligned address is inside the range. 8.4.2.2.2 outside range (address < compa_addr or address > compb_addr) in the outside range comparator mode, comparator pair a and b can be con?ured for range comparisons. a single match condition on either of the comparators is recognized as valid. an aligned word access which straddles the range boundary is valid only if the aligned address is outside the range. outside range mode in combination with tagging can be used to detect if the opcode fetches are from an unexpected range. in forced match mode the outside range match would typically be activated at any interrupt vector fetch or register access. this can be avoided by setting the upper range limit to $3ffff or lower range limit to $00000 respectively. 8.4.3 match modes (forced or tagged) match modes are used as quali?rs for a state sequencer change of state. the comparator control register tag bits select the match mode. the modes are described in the following sections. 8.4.3.1 forced match when con?ured for forced matching, a comparator channel match can immediately initiate a transition to the next state sequencer state whereby the corresponding ?gs in dbgsr are set. the state control register for the current state determines the next state. forced matches are typically generated 2-3 bus cycles after the ?al matching address bus cycle, independent of comparator rwe/rw settings. furthermore since opcode fetches occur several cycles before the opcode execution a forced match of an opcode address typically precedes a tagged match at the same address. 8.4.3.2 tagged match if a cpu taghit occurs a transition to another state sequencer state is initiated and the corresponding dbgsr ?gs are set. for a comparator related taghit to occur, the dbg must ?st attach tags to instructions as they are fetched from memory. when the tagged instruction reaches the execution stage of the instruction queue a taghit is generated by the cpu. this can initiate a state sequencer transition.
s12s debug module (s12sdbgv2) mc9s12g family reference manual, rev.1.23 338 freescale semiconductor 8.4.3.3 immediate trigger independent of comparator matches it is possible to initiate a tracing session and/or breakpoint by writing to the trig bit in dbgc1. if con?ured for begin aligned tracing, this triggers the state sequencer into the final state, if con?ured for end alignment, setting the trig bit disarms the module, ending the session and issues a forced breakpoint request to the cpu. it is possible to set both trig and arm simultaneously to generate an immediate trigger, independent of the current state of arm. 8.4.3.4 channel priorities in case of simultaneous matches the priority is resolved according to table 8-36 . the lower priority is suppressed. it is thus possible to miss a lower priority match if it occurs simultaneously with a higher priority. the priorities described in table 8-36 dictate that in the case of simultaneous matches, the match pointing to ?al state has highest priority followed by the lower channel number (0,1,2). 8.4.4 state sequence control figure 8-24. state sequencer diagram the state sequencer allows a de?ed sequence of events to provide a trigger point for tracing of data in the trace buffer. once the dbg module has been armed by setting the arm bit in the dbgc1 register, then state1 of the state sequencer is entered. further transitions between the states are then controlled by the state control registers and channel matches. from final state the only permitted transition is back to the table 8-36. channel priorities priority source action highest trig enter final state channel pointing to final state transition to next state as de?ed by state control registers match0 (force or tag hit) transition to next state as de?ed by state control registers match1 (force or tag hit) transition to next state as de?ed by state control registers lowest match2 (force or tag hit) transition to next state as de?ed by state control registers state1 final state state3 arm = 1 session complete (disarm) state2 state 0 (disarmed) arm = 0 arm = 0 arm = 0
s12s debug module (s12sdbgv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 339 disarmed state0. transition between any of the states 1 to 3 is not restricted. each transition updates the ssf[2:0] ?gs in dbgsr accordingly to indicate the current state. alternatively writing to the trig bit in dbgsc1, provides an immediate trigger independent of comparator matches. independent of the state sequencer, each comparator channel can be individually con?ured to generate an immediate breakpoint when a match occurs through the use of the brk bits in the dbgxctl registers. thus it is possible to generate an immediate breakpoint on selected channels, whilst a state sequencer transition can be initiated by a match on other channels. if a debug session is ended by a match on a channel the state sequencer transitions through final state for a clock cycle to state0. this is independent of tracing and breakpoint activity, thus with tracing and breakpoints disabled, the state sequencer enters state0 and the debug module is disarmed. 8.4.4.1 final state on entering final state a trigger may be issued to the trace buffer according to the trace alignment control as de?ed by the talign bit (see section 8.3.2.3, ?ebug trace control register (dbgtcr) ). if the tsource bit in dbgtcr is clear then the trace buffer is disabled and the transition to final state can only generate a breakpoint request. in this case or upon completion of a tracing session when tracing is enabled, the arm bit in the dbgc1 register is cleared, returning the module to the disarmed state0. if tracing is enabled a breakpoint request can occur at the end of the tracing session. if neither tracing nor breakpoints are enabled then when the ?al state is reached it returns automatically to state0 and the debug module is disarmed. 8.4.5 trace buffer operation the trace buffer is a 64 lines deep by 20-bits wide ram array. the dbg module stores trace information in the ram array in a circular buffer format. the system accesses the ram array through a register window (dbgtbh:dbgtbl) using 16-bit wide word accesses. after each complete 20-bit trace buffer line is read, an internal pointer into the ram increments so that the next read receives fresh information. data is stored in the format shown in table 8-37 and table 8-40 . after each store the counter register dbgcnt is incremented. tracing of cpu activity is disabled when the bdm is active. reading the trace buffer whilst the dbg is armed returns invalid data and the trace buffer pointer is not incremented. 8.4.5.1 trace trigger alignment using the talign bit (see section 8.3.2.3, ?ebug trace control register (dbgtcr) ) it is possible to align the trigger with the end or the beginning of a tracing session. if end alignment is selected, tracing begins when the arm bit in dbgc1 is set and state1 is entered; the transition to final state signals the end of the tracing session. tracing with begin-trigger starts at the opcode of the trigger. using end alignment or when the tracing is initiated by writing to the trig bit whilst con?ured for begin alignment, tracing starts in the second cycle after the dbgc1 write cycle.
s12s debug module (s12sdbgv2) mc9s12g family reference manual, rev.1.23 340 freescale semiconductor 8.4.5.1.1 storing with begin trigger alignment storing with begin alignment, data is not stored in the trace buffer until the final state is entered. once the trigger condition is met the dbg module remains armed until 64 lines are stored in the trace buffer. if the trigger is at the address of the change-of-?w instruction the change of ?w associated with the trigger is stored in the trace buffer. using begin alignment together with tagging, if the tagged instruction is about to be executed then the trace is started. upon completion of the tracing session the breakpoint is generated, thus the breakpoint does not occur at the tagged instruction boundary. 8.4.5.1.2 storing with end trigger alignment storing with end alignment, data is stored in the trace buffer until the final state is entered, at which point the dbg module becomes disarmed and no more data is stored. if the trigger is at the address of a change of ?w instruction, the trigger event is not stored in the trace buffer. if all trace buffer lines have been used before a trigger event occurrs then the trace continues at the ?st line, overwriting the oldest entries. 8.4.5.2 trace modes four trace modes are available. the mode is selected using the trcmod bits in the dbgtcr register. tracing is enabled using the tsource bit in the dbgtcr register. the modes are described in the following subsections. 8.4.5.2.1 normal mode in normal mode, change of ?w (cof) program counter (pc) addresses are stored. cof addresses are de?ed as follows: source address of taken conditional branches (long, short, bit-conditional, and loop primitives) destination address of indexed jmp, jsr, and call instruction destination address of rti, rts, and rtc instructions vector address of interrupts, except for bdm vectors lbra, bra, bsr, bgnd as well as non-indexed jmp, jsr, and call instructions are not classi?d as change of ?w and are not stored in the trace buffer. stored information includes the full 18-bit address bus and information bits, which contains a source/destination bit to indicate whether the stored address was a source address or destination address. note when a cof instruction with destination address is executed, the destination address is stored to the trace buffer on instruction completion, indicating the cof has taken place. if an interrupt occurs simultaneously then the next instruction carried out is actually from the interrupt service routine. the instruction at the destination address of the original program ?w gets executed after the interrupt service routine.
s12s debug module (s12sdbgv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 341 in the following example an irq interrupt occurs during execution of the indexed jmp at address mark1. the brn at the destination (sub_1) is not executed until after the irq service routine but the destination address is entered into the trace buffer to indicate that the indexed jmp cof has taken place. ldx #sub_1 mark1 jmp 0,x ; irq interrupt occurs during execution of this mark2 nop ; sub_1 brn * ; jmp destination address trace buffer entry 1 ; rti destination address trace buffer entry 3 nop ; addr1 dbne a,part5 ; source address trace buffer entry 4 irq_isr ldab #$f0 ; irq vector $fff2 = trace buffer entry 2 stab var_c1 rti ; the execution ?w taking into account the irq is as follows ldx #sub_1 mark1 jmp 0,x ; irq_isr ldab #$f0 ; stab var_c1 rti ; sub_1 brn * nop ; addr1 dbne a,part5 ; 8.4.5.2.2 loop1 mode loop1 mode, similarly to normal mode also stores only cof address information to the trace buffer, it however allows the ?tering out of redundant information. the intent of loop1 mode is to prevent the trace buffer from being ?led entirely with duplicate information from a looping construct such as delays using the dbne instruction or polling loops using brset/brclr instructions. immediately after address information is placed in the trace buffer, the dbg module writes this value into a background register. this prevents consecutive duplicate address entries in the trace buffer resulting from repeated branches. loop1 mode only inhibits consecutive duplicate source address entries that would typically be stored in most tight looping constructs. it does not inhibit repeated entries of destination addresses or vector addresses, since repeated entries of these would most likely indicate a bug in the users code that the dbg module is designed to help ?d. 8.4.5.2.3 detail mode in detail mode, address and data for all memory and register accesses is stored in the trace buffer. this mode is intended to supply additional information on indexed, indirect addressing modes where storing only the destination address would not provide all information required for a user to determine where the code is in error. this mode also features information bit storage to the trace buffer, for each address byte
s12s debug module (s12sdbgv2) mc9s12g family reference manual, rev.1.23 342 freescale semiconductor storage. the information bits indicate the size of access (word or byte) and the type of access (read or write). when tracing in detail mode, all cycles are traced except those when the cpu is either in a free or opcode fetch cycle. 8.4.5.2.4 compressed pure pc mode in compressed pure pc mode, the pc addresses of all executed opcodes, including illegal opcodes are stored. a compressed storage format is used to increase the effective depth of the trace buffer. this is achieved by storing the lower order bits each time and using 2 information bits to indicate if a 64 byte boundary has been crossed, in which case the full pc is stored. each trace buffer row consists of 2 information bits and 18 pc address bits note: when tracing is terminated using forced breakpoints, latency in breakpoint generation means that opcodes following the opcode causing the breakpoint can be stored to the trace buffer. the number of opcodes is dependent on program ?w. this can be avoided by using tagged breakpoints. 8.4.5.3 trace buffer organization (normal, loop1, detail modes) adrh, adrm, adrl denote address high, middle and low byte respectively. the numerical suf? refers to the tracing count. the information format for loop1 and normal modes is identical. in detail mode, the address and data for each entry are stored on consecutive lines, thus the maximum number of entries is 32. in this case dbgcnt bits are incremented twice, once for the address line and once for the data line, on each trace buffer entry. in detail mode cinf comprises of r/w and size access information (crw and csz respectively). single byte data accesses in detail mode are always stored to the low byte of the trace buffer (datal) and the high byte is cleared. when tracing word accesses, the byte at the lower address is always stored to trace buffer byte1 and the byte at the higher address is stored to byte0. table 8-37. trace buffer organization (normal,loop1,detail modes) mode entry number 4-bits 8-bits 8-bits field 2 field 1 field 0 detail mode entry 1 cinf1,adrh1 adrm1 adrl1 0 datah1 datal1 entry 2 cinf2,adrh2 adrm2 adrl2 0 datah2 datal2 normal/loop1 modes entry 1 pch1 pcm1 pcl1 entry 2 pch2 pcm2 pcl2
s12s debug module (s12sdbgv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 343 8.4.5.3.1 information bit organization the format of the bits is dependent upon the active trace mode as described below. field2 bits in detail mode in detail mode the csz and crw bits indicate the type of access being made by the cpu. field2 bits in normal and loop1 modes bit 3 bit 2 bit 1 bit 0 csz crw addr[17] addr[16] figure 8-25. field2 bits in detail mode table 8-38. field descriptions bit description 3 csz access type indicator ?this bit indicates if the access was a byte or word size when tracing in detail mode 0 word access 1 byte access 2 crw read write indicator ?this bit indicates if the corresponding stored address corresponds to a read or write access when tracing in detail mode. 0 write access 1 read access 1 addr[17] address bus bit 17 ?corresponds to system address bus bit 17. 0 addr[16] address bus bit 16 ?corresponds to system address bus bit 16. bit 3 bit 2 bit 1 bit 0 csd cva pc17 pc16 figure 8-26. information bits pch table 8-39. pch field descriptions bit description 3 csd source destination indicator ?in normal and loop1 mode this bit indicates if the corresponding stored address is a source or destination address. this bit has no meaning in compressed pure pc mode. 0 source address 1 destination address 2 cva vector indicator in normal and loop1 mode this bit indicates if the corresponding stored address is a vector address. vector addresses are destination addresses, thus if cva is set, then the corresponding csd is also set. this bit has no meaning in compressed pure pc mode. 0 non-vector destination address 1 vector destination address 1 pc17 program counter bit 17 ?in normal and loop1 mode this bit corresponds to program counter bit 17.
s12s debug module (s12sdbgv2) mc9s12g family reference manual, rev.1.23 344 freescale semiconductor 8.4.5.4 trace buffer organization (compressed pure pc mode) table 8-40. trace buffer organization example (compressed purepc mode) note con?ured for end aligned triggering in compressed purepc mode, then after rollover it is possible that the oldest base address is overwritten. in this case all entries between the pointer and the next base address have lost their base address following rollover. for example in table 8-40 if one line of rollover has occurred, line 1, pc1, is overwritten with a new entry. thus the entries on lines 2 and 3 have lost their base address. for reconstruction of program ?w the ?st base address following the pointer must be used, in the example, line 4. the pointer points to the oldest entry, line 2. field3 bits in compressed pure pc modes each time that pc[17:6] differs from the previous base pc[17:6], then a new base address is stored. the base address zero value is the lowest address in the 64 address range the ?st line of the trace buffer always gets a base pc address, this applies also on rollover. 0 pc16 program counter bit 16 ?in normal and loop1 mode this bit corresponds to program counter bit 16. mode line number 2-bits 6-bits 6-bits 6-bits field 3 field 2 field 1 field 0 compressed pure pc mode line 1 00 pc1 (initial 18-bit pc base address) line 2 11 pc4 pc3 pc2 line 3 01 0 0 pc5 line 4 00 pc6 (new 18-bit pc base address) line 5 10 0 pc8 pc7 line 6 00 pc9 (new 18-bit pc base address) table 8-41. compressed pure pc mode field 3 information bit encoding inf1 inf0 trace buffer row content 0 0 base pc address tb[17:0] contains a full pc[17:0] value 0 1 trace buffer[5:0] contain incremental pc relative to base address zero value 1 0 trace buffer[11:0] contain next 2 incremental pcs relative to base address zero value 1 1 trace buffer[17:0] contain next 3 incremental pcs relative to base address zero value table 8-39. pch field descriptions (continued) bit description
s12s debug module (s12sdbgv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 345 8.4.5.5 reading data from trace buffer the data stored in the trace buffer can be read provided the dbg module is not armed, is con?ured for tracing (tsource bit is set) and the system not secured. when the arm bit is written to 1 the trace buffer is locked to prevent reading. the trace buffer can only be unlocked for reading by a single aligned word write to dbgtb when the module is disarmed. the trace buffer can only be read through the dbgtb register using aligned word reads, any byte or misaligned reads return 0 and do not cause the trace buffer pointer to increment to the next trace buffer address. the trace buffer data is read out ?st-in ?st-out. by reading cnt in dbgcnt the number of valid lines can be determined. dbgcnt does not decrement as data is read. whilst reading an internal pointer is used to determine the next line to be read. after a tracing session, the pointer points to the oldest data entry, thus if no rollover has occurred, the pointer points to line0, otherwise it points to the line with the oldest entry. in compressed pure pc mode on rollover the line with the oldest data entry may also contain newer data entries in ?lds 0 and 1. thus if rollover is indicated by the tbf bit, the line status must be decoded using the inf bits in ?ld3 of that line. if both inf bits are clear then the line contains only entries from before the last rollover. if inf0=1 then ?ld 0 contains post rollover data but ?lds 1 and 2 contain pre rollover data. if inf1=1 then ?lds 0 and 1 contain post rollover data but ?ld 2 contains pre rollover data. the pointer is initialized by each aligned write to dbgtbh to point to the oldest data again. this enables an interrupted trace buffer read sequence to be easily restarted from the oldest data entry. the least signi?ant word of line is read out ?st. this corresponds to the ?lds 1 and 0 of table 8-37 . the next word read returns ?ld 2 in the least signi?ant bits [3:0] and ??for bits [15:4]. reading the trace buffer while the dbg module is armed returns invalid data and no shifting of the ram pointer occurs. 8.4.5.6 trace buffer reset state the trace buffer contents and dbgcnt bits are not initialized by a system reset. thus should a system reset occur, the trace session information from immediately before the reset occurred can be read out and the number of valid lines in the trace buffer is indicated by dbgcnt. the internal pointer to the current trace buffer address is initialized by unlocking the trace buffer and points to the oldest valid data even if a reset occurred during the tracing session. to read the trace buffer after a reset, tsource must be set, otherwise the trace buffer reads as all zeroes. generally debugging occurrences of system resets is best handled using end trigger alignment since the reset may occur before the trace trigger, which in the begin trigger alignment case means no information would be stored in the trace buffer. the trace buffer contents and dbgcnt bits are unde?ed following a por. note an external pin reset that occurs simultaneous to a trace buffer entry can, in very seldom cases, lead to either that entry being corrupted or the ?st entry of the session being corrupted. in such cases the other contents of the trace buffer still contain valid tracing information. the case occurs when the reset assertion coincides with the trace buffer entry clock edge.
s12s debug module (s12sdbgv2) mc9s12g family reference manual, rev.1.23 346 freescale semiconductor 8.4.6 tagging a tag follows program information as it advances through the instruction queue. when a tagged instruction reaches the head of the queue a tag hit occurs and can initiate a state sequencer transition. each comparator control register features a tag bit, which controls whether the comparator match causes a state sequencer transition immediately or tags the opcode at the matched address. if a comparator is enabled for tagged comparisons, the address stored in the comparator match address registers must be an opcode address. using begin trigger together with tagging, if the tagged instruction is about to be executed then the transition to the next state sequencer state occurs. if the transition is to the final state, tracing is started. only upon completion of the tracing session can a breakpoint be generated. using end alignment, when the tagged instruction is about to be executed and the next transition is to final state then a breakpoint is generated immediately, before the tagged instruction is carried out. r/w monitoring, access size (sz) monitoring and data bus monitoring are not useful if tagging is selected, since the tag is attached to the opcode at the matched address and is not dependent on the data bus nor on the type of access. thus these bits are ignored if tagging is selected. when con?ured for range comparisons and tagging, the ranges are accurate only to word boundaries. tagging is disabled when the bdm becomes active. 8.4.7 breakpoints it is possible to generate breakpoints from channel transitions to ?al state or using software to write to the trig bit in the dbgc1 register. 8.4.7.1 breakpoints from comparator channels breakpoints can be generated when the state sequencer transitions to the final state. if con?ured for tagging, then the breakpoint is generated when the tagged opcode reaches the execution stage of the instruction queue. if a tracing session is selected by the tsource bit, breakpoints are requested when the tracing session has completed, thus if begin aligned triggering is selected, the breakpoint is requested only on completion of the subsequent trace (see table 8-42 ). if no tracing session is selected, breakpoints are requested immediately. if the brk bit is set, then the associated breakpoint is generated immediately independent of tracing trigger alignment. table 8-42. breakpoint setup for cpu breakpoints brk talign dbgbrk breakpoint alignment 0 0 0 fill trace buffer until trigger then disarm (no breakpoints) 0 0 1 fill trace buffer until trigger, then breakpoint request occurs 0 1 0 start trace buffer at trigger (no breakpoints)
s12s debug module (s12sdbgv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 347 8.4.7.2 breakpoints generated via the trig bit if a trig triggers occur, the final state is entered whereby tracing trigger alignment is de?ed by the talign bit. if a tracing session is selected by the tsource bit, breakpoints are requested when the tracing session has completed, thus if begin aligned triggering is selected, the breakpoint is requested only on completion of the subsequent trace (see table 8-42 ). if no tracing session is selected, breakpoints are requested immediately. trig breakpoints are possible with a single write to dbgc1, setting arm and trig simultaneously. 8.4.7.3 breakpoint priorities if a trig trigger occurs after begin aligned tracing has already started, then the trig no longer has an effect. when the associated tracing session is complete, the breakpoint occurs. similarly if a trig is followed by a subsequent comparator channel match, it has no effect, since tracing has already started. if a forced swi breakpoint coincides with a bgnd in user code with bdm enabled, then the bdm is activated by the bgnd and the breakpoint to swi is suppressed. 8.4.7.3.1 dbg breakpoint priorities and bdm interfacing breakpoint operation is dependent on the state of the bdm module. if the bdm module is active, the cpu is executing out of bdm ?mware, thus comparator matches and associated breakpoints are disabled. in addition, while executing a bdm trace command, tagging into bdm is disabled. if bdm is not active, the breakpoint gives priority to bdm requests over swi requests if the breakpoint happens to coincide with a swi instruction in user code. on returning from bdm, the swi from user code gets executed. bdm cannot be entered from a breakpoint unless the enable bit is set in the bdm. if entry to bdm via a bgnd instruction is attempted and the enable bit in the bdm is cleared, the cpu actually executes the bdm ?mware code, checks the enable and returns if enable is not set. if not serviced by the monitor then the breakpoint is re-asserted when the bdm returns to normal cpu ?w. 0 1 1 start trace buffer at trigger a breakpoint request occurs when trace buffer is full 1 x 1 terminate tracing and generate breakpoint immediately on trigger 1 x 0 terminate tracing immediately on trigger table 8-43. breakpoint mapping summary dbgbrk bdm bit (dbgc1[4]) bdm enabled bdm active breakpoint mapping 0 x x x no breakpoint 1 0 x 0 breakpoint to swi x x 1 1 no breakpoint 1 1 0 x breakpoint to swi 1 1 1 0 breakpoint to bdm table 8-42. breakpoint setup for cpu breakpoints
s12s debug module (s12sdbgv2) mc9s12g family reference manual, rev.1.23 348 freescale semiconductor if the comparator register contents coincide with the swi/bdm vector address then an swi in user code could coincide with a dbg breakpoint. the cpu ensures that bdm requests have a higher priority than swi requests. returning from the bdm/swi service routine care must be taken to avoid a repeated breakpoint at the same address. should a tagged or forced breakpoint coincide with a bgnd in user code, then the instruction that follows the bgnd instruction is the ?st instruction executed when normal program execution resumes. note when program control returns from a tagged breakpoint using an rti or bdm go command without program counter modi?ation it returns to the instruction whose tag generated the breakpoint. to avoid a repeated breakpoint at the same location recon?ure the dbg module in the swi routine, if con?ured for an swi breakpoint, or over the bdm interface by executing a trace command before the go to increment the program ?w past the tagged instruction. 8.5 application information 8.5.1 state machine scenarios de?ing the state control registers as scr1,scr2, scr3 and m0,m1,m2 as matches on channels 0,1,2 respectively. scr encoding supported by s12sdbgv1 are shown in black. scr encoding supported only in s12sdbgv2 are shown in red. for backwards compatibility the new scenarios use a 4th bit in each scr register. thus the existing encoding for scrx[2:0] is not changed. 8.5.2 scenario 1 a trigger is generated if a given sequence of 3 code events is executed. figure 8-27. scenario 1 scenario 1 is possible with s12sdbgv1 scr encoding state1 final state state3 state2 scr1=0011 scr2=0010 scr3=0111 m1 m2 m0
s12s debug module (s12sdbgv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 349 8.5.3 scenario 2 a trigger is generated if a given sequence of 2 code events is executed. figure 8-28. scenario 2a a trigger is generated if a given sequence of 2 code events is executed, whereby the ?st event is entry into a range (compa,compb con?ured for range mode). m1 is disabled in range modes. figure 8-29. scenario 2b a trigger is generated if a given sequence of 2 code events is executed, whereby the second event is entry into a range (compa,compb con?ured for range mode) figure 8-30. scenario 2c all 3 scenarios 2a,2b,2c are possible with the s12sdbgv1 scr encoding 8.5.4 scenario 3 a trigger is generated immediately when one of up to 3 given events occurs figure 8-31. scenario 3 scenario 3 is possible with s12sdbgv1 scr encoding 8.5.5 scenario 4 trigger if a sequence of 2 events is carried out in an incorrect order. event a must be followed by event b and event b must be followed by event a. 2 consecutive occurrences of event a without an intermediate state1 final state state2 scr1=0011 scr2=0101 m1 m2 state1 final state state2 scr1=0111 scr2=0101 m01 m2 state1 final state state2 scr1=0010 scr2=0011 m2 m0 state1 final state scr1=0000 m012
s12s debug module (s12sdbgv2) mc9s12g family reference manual, rev.1.23 350 freescale semiconductor event b cause a trigger. similarly 2 consecutive occurrences of event b without an intermediate event a cause a trigger. this is possible by using compa and compc to match on the same address as shown. figure 8-32. scenario 4a this scenario is currently not possible using 2 comparators only. s12sdbgv2 makes it possible with 2 comparators, state 3 allowing a m0 to return to state 2, whilst a m2 leads to ?al state as shown. figure 8-33. scenario 4b (with 2 comparators) the advantage of using only 2 channels is that now range comparisons can be included (channel0) this however violates the s12sdbgv1 speci?ation, which states that a match leading to ?al state always has priority in case of a simultaneous match, whilst priority is also given to the lowest channel number. for s12sdbg the corresponding cpu priority decoder is removed to support this, such that on simultaneous taghits, taghits pointing to ?al state have highest priority. if no taghit points to ?al state then the lowest channel number has priority. thus with the above encoding from state3, the cpu and dbg would break on a simultaneous m0/m2. state1 state 3 final state state2 m0 m0 m2 m1 m1 m1 scr1=0100 scr2=0011 scr3=0001 state1 state 3 final state state2 m0 m01 m0 m2 m2 m2 scr1=0110 scr2= 1100 scr3= 1110 m1 disabled in range mode
s12s debug module (s12sdbgv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 351 8.5.6 scenario 5 trigger if following event a, event c precedes event b. i.e. the expected execution ?w is a->b->c. figure 8-34. scenario 5 scenario 5 is possible with the s12sdbgv1 scr encoding 8.5.7 scenario 6 trigger if event a occurs twice in succession before any of 2 other events (bc) occurs. this scenario is not possible using the s12sdbgv1 scr encoding. s12sdbgv2 includes additions shown in red. the change in scr1 encoding also has the advantage that a state1->state3 transition using m0 is now possible. this is advantageous because range and data bus comparisons use channel0 only. figure 8-35. scenario 6 8.5.8 scenario 7 trigger when a series of 3 events is executed out of order. specifying the event order as m1,m2,m0 to run in loops (120120120). any deviation from that order should trigger. this scenario is not possible using the s12sdbgv1 scr encoding because or possibilities are very limited in the channel encoding. by adding or forks as shown in red this scenario is possible. figure 8-36. scenario 7 state1 final state state2 scr1=0011 scr2=0110 m1 m0 m2 state1 final state state3 scr1= 1001 scr3= 1010 m0 m0 m12 state1 final state state3 state2 scr1= 1101 scr2= 1100 scr3= 1101 m1 m2 m12 m0 m02 m01
s12s debug module (s12sdbgv2) mc9s12g family reference manual, rev.1.23 352 freescale semiconductor on simultaneous matches the lowest channel number has priority so with this con?uration the forking from state1 has the peculiar effect that a simultaneous match0/match1 transitions to ?al state but a simultaneous match2/match1transitions to state2. 8.5.9 scenario 8 trigger when a routine/event at m2 follows either m1 or m0. figure 8-37. scenario 8a trigger when an event m2 is followed by either event m0 or event m1 figure 8-38. scenario 8b scenario 8a and 8b are possible with the s12sdbgv1 and s12sdbgv2 scr encoding 8.5.10 scenario 9 trigger when a routine/event at a (m2) does not follow either b or c (m1 or m0) before they are executed again. this cannot be realized with thes12sdbgv1 scr encoding due to or limitations. by changing the scr2 encoding as shown in red this scenario becomes possible. figure 8-39. scenario 9 8.5.11 scenario 10 trigger if an event m0 occurs following up to two successive m2 events without the resetting event m1. as shown up to 2 consecutive m2 events are allowed, whereby a reset to state1 is possible after either one or two m2 events. if an event m0 occurs following the second m2, before m1 resets to state1 then a trigger state1 final state state2 scr1=0111 scr2=0101 m01 m2 state1 final state state2 scr1=0010 scr2=0111 m2 m01 state1 final state state2 scr1=0111 scr2= 1111 m01 m01 m2
s12s debug module (s12sdbgv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 353 is generated. con?uring compa and compc the same, it is possible to generate a breakpoint on the third consecutive occurrence of event m0 without a reset m1. figure 8-40. scenario 10a figure 8-41. scenario 10b scenario 10b shows the case that after m2 then m1 must occur before m0. starting from a particular point in code, event m2 must always be followed by m1 before m0. if after any m2, event m0 occurs before m1 then a trigger is generated. state1 final state state3 state2 scr1=0010 scr2=0100 scr3=0010 m2 m2 m0 m1 m1 state1 final state state3 state2 scr1=0010 scr2=0011 scr3=0000 m2 m1 m0 m0
s12s debug module (s12sdbgv2) mc9s12g family reference manual, rev.1.23 354 freescale semiconductor
mc9s12g family reference manual, rev.1.23 freescale semiconductor 355 chapter 9 security (s12xs9secv2) 9.1 introduction this speci?ation describes the function of the security mechanism in the mc9s12g-family (9sec). note no security feature is absolutely secure. however, freescales strategy is to make reading or copying the flash and/or eeprom dif?ult for unauthorized users. 9.1.1 features the user must be reminded that part of the security must lie with the application code. an extreme example would be application code that dumps the contents of the internal memory. this would defeat the purpose of security. at the same time, the user may also wish to put a backdoor in the application program. an example of this is the user downloads a security key through the sci, which allows access to a programming routine that updates parameters stored in another section of the flash memory. the security features of the mc9s12g-family (in secure mode) are: protect the content of non-volatile memories (flash, eeprom) execution of nvm commands is restricted disable access to internal memory via background debug module (bdm) 9.1.2 modes of operation table 9-2 gives an overview over availability of security relevant features in unsecure and secure modes. table 9-1. revision history revision number revision date sections affected description of changes 02.00 27 aug 2004 reviewed and updated for s12xd architecture 02.01 21 feb 2007 added s12xe, s12xf and s12xs architectures 02.02 19 apr 2007 corrected statement about backdoor key access via bdm on xe, xf, xs table 9-2. feature availability in unsecure and secure modes on s12xs unsecure mode secure mode ns ss nx es ex st ns ss nx es ex st flash array access ?? ??
security (s12xs9secv2) mc9s12g family reference manual, rev.1.23 356 freescale semiconductor 9.1.3 securing the microcontroller once the user has programmed the flash and eeprom, the chip can be secured by programming the security bits located in the options/security byte in the flash memory array. these non-volatile bits will keep the device secured through reset and power-down. the options/security byte is located at address 0xff0f (= global address 0x7f_ff0f) in the flash memory array. this byte can be erased and programmed like any other flash location. two bits of this byte are used for security (sec[1:0]). on devices which have a memory page window, the flash options/security byte is also available at address 0xbf0f by selecting page 0x3f with the ppage register. the contents of this byte are copied into the flash security register (fsec) during a reset sequence. the meaning of the bits keyen[1:0] is shown in table 9-3 . please refer to section 9.1.5.1, ?nsecuring the mcu using the backdoor key access for more information. the meaning of the security bits sec[1:0] is shown in table 9-4 . for security reasons, the state of device security is controlled by two bits. to put the device in unsecured mode, these bits must be programmed to sec[1:0] = ?0? all other combinations put the device in a secured mode. the recommended value to put the device in secured state is the inverse of the unsecured state, i.e. sec[1:0] = ?1? eeprom array access ?? ?? nvm commands ? 1 ? ? 1 ? 1 bdm ?? ? 2 dbg module trace ?? 1 restricted nvm command set only. please refer to the nvm wrapper block guides for detailed information. 2 bdm hardware commands restricted to peripheral registers only. 76543210 0xff0f keyen1 keyen0 nv5 nv4 nv3 nv2 sec1 sec0 figure 9-1. flash options/security byte table 9-3. backdoor key access enable bits keyen[1:0] backdoor key access enabled 00 0 (disabled) 01 0 (disabled) 10 1 (enabled) 11 0 (disabled) table 9-2. feature availability in unsecure and secure modes on s12xs unsecure mode secure mode ns ss nx es ex st ns ss nx es ex st
security (s12xs9secv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 357 note please refer to the flash block guide for actual security con?uration (in section ?lash module security?. 9.1.4 operation of the secured microcontroller by securing the device, unauthorized access to the eeprom and flash memory contents can be prevented. however, it must be understood that the security of the eeprom and flash memory contents also depends on the design of the application program. for example, if the application has the capability of downloading code through a serial port and then executing that code (e.g. an application containing bootloader code), then this capability could potentially be used to read the eeprom and flash memory contents even when the microcontroller is in the secure state. in this example, the security of the application could be enhanced by requiring a challenge/response authentication before any code can be downloaded. secured operation has the following effects on the microcontroller: 9.1.4.1 normal single chip mode (ns) background debug module (bdm) operation is completely disabled. execution of flash and eeprom commands is restricted. please refer to the nvm block guide for details. tracing code execution using the dbg module is disabled. 9.1.4.2 special single chip mode (ss) bdm ?mware commands are disabled. bdm hardware commands are restricted to the register space. execution of flash and eeprom commands is restricted. please refer to the nvm block guide for details. tracing code execution using the dbg module is disabled. special single chip mode means bdm is active after reset. the availability of bdm ?mware commands depends on the security state of the device. the bdm secure ?mware ?st performs a blank check of both the flash memory and the eeprom. if the blank check succeeds, security will be temporarily turned off and the state of the security bits in the appropriate flash memory location can be changed if the blank check fails, security will remain active, only the bdm hardware commands will be enabled, and the accessible memory space is restricted to the peripheral register area. this will allow the bdm to be used to erase the eeprom and flash memory without giving access to their contents. after erasing both flash table 9-4. security bits sec[1:0] security state 00 1 (secured) 01 1 (secured) 10 0 (unsecured) 11 1 (secured)
security (s12xs9secv2) mc9s12g family reference manual, rev.1.23 358 freescale semiconductor memory and eeprom, another reset into special single chip mode will cause the blank check to succeed and the options/security byte can be programmed to ?nsecured?state via bdm. while the bdm is executing the blank check, the bdm interface is completely blocked, which means that all bdm commands are temporarily blocked. 9.1.5 unsecuring the microcontroller unsecuring the microcontroller can be done by three different methods: 1. backdoor key access 2. reprogramming the security bits 3. complete memory erase (special modes) 9.1.5.1 unsecuring the mcu using the backdoor key access in normal modes (single chip and expanded), security can be temporarily disabled using the backdoor key access method. this method requires that: the backdoor key at 0xff00?xff07 (= global addresses 0x3_ff00?x3_ff07) has been programmed to a valid value. the keyen[1:0] bits within the flash options/security byte select ?nabled? in single chip mode, the application program programmed into the microcontroller must be designed to have the capability to write to the backdoor key locations. the backdoor key values themselves would not normally be stored within the application data, which means the application program would have to be designed to receive the backdoor key values from an external source (e.g. through a serial port). the backdoor key access method allows debugging of a secured microcontroller without having to erase the flash. this is particularly useful for failure analysis. note no word of the backdoor key is allowed to have the value 0x0000 or 0xffff. 9.1.6 reprogramming the security bits in normal single chip mode (ns), security can also be disabled by erasing and reprogramming the security bits within flash options/security byte to the unsecured value. because the erase operation will erase the entire sector from 0xfe00?xffff (0x7f_fe00?x7f_ffff), the backdoor key and the interrupt vectors will also be erased; this method is not recommended for normal single chip mode. the application software can only erase and program the flash options/security byte if the flash sector containing the flash options/security byte is not protected (see flash protection). thus flash protection is a useful means of preventing this method. the microcontroller will enter the unsecured state after the next reset following the programming of the security bits to the unsecured value. this method requires that:
security (s12xs9secv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 359 the application software previously programmed into the microcontroller has been designed to have the capability to erase and program the flash options/security byte, or security is ?st disabled using the backdoor key method, allowing bdm to be used to issue commands to erase and program the flash options/security byte. the flash sector containing the flash options/security byte is not protected. 9.1.7 complete memory erase (special modes) the microcontroller can be unsecured in special modes by erasing the entire eeprom and flash memory contents. when a secure microcontroller is reset into special single chip mode (ss), the bdm ?mware veri?s whether the eeprom and flash memory are erased. if any eeprom or flash memory address is not erased, only bdm hardware commands are enabled. bdm hardware commands can then be used to write to the eeprom and flash registers to mass erase the eeprom and all flash memory blocks. when next reset into special single chip mode, the bdm ?mware will again verify whether all eeprom and flash memory are erased, and this being the case, will enable all bdm commands, allowing the flash options/security byte to be programmed to the unsecured value. the security bits sec[1:0] in the flash security register will indicate the unsecure state following the next reset.
security (s12xs9secv2) mc9s12g family reference manual, rev.1.23 360 freescale semiconductor
mc9s12g family reference manual, rev.1.23 freescale semiconductor 361 chapter 10 s12 clock, reset and power management unit (s12cpmu) revision history 10.1 introduction this speci?ation describes the function of the clock, reset and power management unit (s12cpmu). the pierce oscillator (xosclcp) provides a robust, low-noise and low-power external clock source. it is designed for optimal start-up margin with typical quartz crystals and ceramic resonators. the voltage regulator (ivreg) operates from the range 3.13v to 5.5v. it provides all the required chip internal voltages and voltage monitors. the phase locked loop (pll) provides a highly accurate frequency multiplier with internal ?ter. the internal reference clock (irc1m) provides a1mhz clock. 10.1.1 features the pierce oscillator (xosclcp) contains circuitry to dynamically control current gain in the output amplitude. this ensures a signal with low harmonic distortion, low power and good noise immunity. supports quartz crystals or ceramic resonators from 4mhz to 16mhz. high noise immunity due to input hysteresis and spike ?tering. low rf emissions with peak-to-peak swing limited dynamically transconductance (gm) sized for optimum start-up margin for typical crystals version number revision date effective date author description of changes v04.10 01 jul 10 01 jul 10 added tc trimming to feature list v04.11 23 aug 10 23 aug 10 removed feature of adaptive oscillator ?ter. register bits 6 and 4to 0in the cpmuosc register are marked reserved and do not alter. v04.12 27 april 12 27 april 12 corrected wording for api interrupt ?g changed notation of irc trim values for 0x00000 to 0b00000
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 362 freescale semiconductor dynamic gain control eliminates the need for external current limiting resistor integrated resistor eliminates the need for external bias resistor. low power consumption: operates from internal 1.8v (nominal) supply, amplitude control limits power the voltage regulator (ivreg) has the following features: input voltage range from 3.13v to 5.5v low-voltage detect (lvd) with low-voltage interrupt (lvi) power-on reset (por) low-voltage reset (lvr) the phase locked loop (pll) has the following features: highly accurate and phase locked frequency multiplier con?urable internal ?ter for best stability and lock time. frequency modulation for de?ed jitter and reduced emission automatic frequency lock detector interrupt request on entry or exit from locked condition reference clock either external (crystal) or internal square wave (1mhz irc1m) based. pll stability is suf?ient for lin communication, even if using irc1m as reference clock the internal reference clock (irc1m) has the following features: frequency trimming (a factory trim value for 1mhz is loaded from flash memory into the irctrim register after reset, which can be overwritten by application if required) temperature coef?ient (tc) trimming. (a factory trim value is loaded from flash memory into the irctrim register to turned off tc trimming after reset. application can trim the tc if required by overwriting the irctrim register). other features of the s12cpmu include clock monitor to detect loss of crystal autonomous periodical interrupt (api) bus clock generator clock switch to select either pllclk or external crystal/resonator based bus clock pllclk divider to adjust system speed system reset generation from the following possible sources: power-on reset (por) low-voltage reset (lvr) illegal address access cop time out
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 freescale semiconductor 363 loss of oscillation (clock monitor fail) external pin reset
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 364 freescale semiconductor 10.1.2 modes of operation this subsection lists and brie? describes all operating modes supported by the s12cpmu. 10.1.2.1 run mode the voltage regulator is in full performance mode (fpm). the phase locked loop (pll) is on. the internal reference clock (irc1m) is on. the api is available. pll engaged internal (pei) this is the default mode after system reset and power-on reset. the bus clock is based on the pllclk. after reset the pll is con?ured for 50 mhz vcoclk operation post divider is 0x03, so pllclk is vcoclk divided by 4, that is 12.5mhz and bus clock is 6.25mhz. the pll can be re-con?ured for other bus frequencies. the reference clock for the pll (refclk) is based on internal reference clock irc1m pll engaged external (pee) the bus clock is based n the pllclk. this mode can be entered from default mode pei by performing the following steps: con?ure the pll for desired bus frequency. program the reference divider (refdiv[3:0] bits) to divide down oscillator frequency if necessary. enable the external oscillator (osce bit) wait for oscillator to start up (uposc=1) and pll to lock (lock=1). pll bypassed external (pbe) the bus clock is based on the oscillator clock (oscclk). the pllclk is always on to qualify the external oscillator clock. therefore it is necessary to make sure a valid pll con?uration is used for the selected oscillator frequency. this mode can be entered from default mode pei by performing the following steps: make sure the pll con?uration is valid for the selected oscillator frequency. enable the external oscillator (osce bit) wait for oscillator to start up (uposc=1) select the oscillator clock (oscclk) as bus clock (pllsel=0). the pllclk is on and used to qualify the external oscillator clock. 10.1.2.2 wait mode for s12cpmu wait mode is the same as run mode.
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 freescale semiconductor 365
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 366 freescale semiconductor 10.1.2.3 stop mode this mode is entered by executing the cpu stop instruction. the voltage regulator is in reduced power mode (rpm). the api is available. the phase locked loop (pll) is off. the internal reference clock (irc1m) is off. core clock, bus clock and bdm clock are stopped. depending on the setting of the pstp and the osce bit, stop mode can be differentiated between full stop mode (pstp = 0 or osce=0) and pseudo stop mode (pstp = 1 and osce=1). in addition, the behavior of the cop in each mode will change based on the clocking method selected by coposcsel[1:0]. full stop mode (pstp = 0 or osce=0) external oscillator (xosclcp) is disabled. if coposcsel1=0: the cop and rti counters halt during full stop mode. after wake-up from full stop mode the core clock and bus clock are running on pllclk (pllsel=1). cop and rti are running on ircclk (coposcsel0=0, rtioscsel=0). if coposcsel1=1: during full stop mode the cop is running on aclk (trimmable internal rc-oscillator clock) and the rti counter halts. after wake-up from full stop mode the core clock and bus clock are running on pllclk (pllsel=1). the cop runs on aclk and rti is running on ircclk (coposcsel0=0, rtioscsel=0). pseudo stop mode (pstp = 1 and osce=1) external oscillator (xosclcp) continues to run. if coposcsel1=0: if the respective enable bits are set (pce=1 and pre=1) the cop and rti will continue to run with a clock derived from the oscillator clock. the clock con?uration bits pllsel, coposcsel0, rtioscsel are unchanged. if coposcsel1=1: if the respective enable bit for the rti is set (pre=1) the rti will continue to run with a clock derived from the oscillator clock. the cop will continue to run on aclk. the clock con?uration bits pllsel, coposcsel0, rtioscsel are unchanged. note when starting up the external oscillator (either by programming osce bit to 1 or on exit from full stop mode with osce bit already 1) the software must wait for a minimum time equivalent to the startup-time of the external oscillator t uposc before entering pseudo stop mode.
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 freescale semiconductor 367 10.1.3 s12cpmu block diagram figure 10-1. block diagram of s12cpmu s12cpmu extal xtal system reset power-on detect pll lock interrupt mmc illegal address access cop time out loop reference divider cop watchdog voltage vddr internal reset generator divide by phase post divider 1,2,.,32 vcoclk eclk2x lockie irctrim[9:0] syndiv[5:0] lock refdiv[3:0] 2*(syndiv+1) pierce oscillator 4mhz-16mhz osce ilaf porf divide by 2 eclk postdiv[4:0] power-on reset controlled locked loop with internal filter (pll) refclk fbclk reffrq[1:0] vcofrq[1:0] lock detect regulator 3.13 to 5.5v autonomous periodic interrupt (api) api interrupt vdda vssa pllsel (to mscan) vddx vssx vss low voltage detect vddx lvrf pllclk reference divide by 8 bdm clock clock (irc1m) clock monitor monitor fail real time interrupt (rti) rti interrupt pstp cpmurti oscillator status interrupt (xosclcp) can_oscclk low voltage interrupt aclk apiclk rticlk ircclk oscclk rtioscsel cpmucop copclk ircclk oscclk coposcsel0 to reset generator cop time out pce pre uposc=0 sets pllsel bit api_extclk rc osc. vdd, vddf (core supplies) uposc reset oscie apie rtie lvds lvie low voltage detect vdda uposc uposc=0 clears & oscclk divide by 4 bus clock ircclk (to lcd) aclk coposcsel1 (bus clock) (core clock) oscclk_lcp external
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 368 freescale semiconductor figure 10-2 shows a block diagram of the xosclcp. figure 10-2. xosclcp block diagram extal xtal gain control vdd = 1.8 v rf oscclk_lcp peak detector vss vss vss c1 c2 quartz crystals ceramic resonators or clock monitor monitor fail
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 freescale semiconductor 369 10.2 signal description this section lists and describes the signals that connect off chip. 10.2.1 reset pin reset is an active-low bidirectional pin. as an input it initializes the mcu asynchronously to a known start-up state. as an open-drain output it indicates that an mcu-internal reset has been triggered. 10.2.2 extal and xtal these pins provide the interface for a crystal to control the internal clock generator circuitry. extal is the input to the crystal oscillator ampli?r. xtal is the output of the crystal oscillator ampli?r. if xosclcp is enabled, the mcu internal oscclk_lcp is derived from the extal input frequency. if osce=0, the extal pin is pulled down by an internal resistor of approximately 200 k ? and the xtal pin is pulled down by an internal resistor of approximately 700 k ? . note freescale recommends an evaluation of the application board and chosen resonator or crystal by the resonator or crystal supplier. the loop controlled circuit (xosclcp) is not suited for overtone resonators and crystals. 10.2.3 vddr ?regulator power input pin pin vddr is the power input of ivreg. all currents sourced into the regulator loads ?w through this pin. an off-chip decoupling capacitor (100 nf...220 nf, x7r ceramic) between vddr and vss can smooth ripple on vddr. 10.2.4 vss ?ground pin vss must be grounded. 10.2.5 vdda, vssa ?regulator reference supply pins pins vdda and vssa are used to supply the analog parts of the regulator. internal precision reference circuits are supplied from these signals. an off-chip decoupling capacitor (100 nf...220 nf, x7r ceramic) between vdda and vssa can improve the quality of this supply. 10.2.6 vddx, vssx?pad supply pins this supply domain is monitored by the low voltage reset circuit.
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 370 freescale semiconductor an off-chip decoupling capacitor (100 nf...220 nf, x7r ceramic) between vddx and vssx can improve the quality of this supply. note depending on the device package following device supply pins are maybe combined into one pin: vddr, vddx and vdda. depending on the device package following device supply pins are maybe combined into one pin: vss, vssx and vssa. please refer to the device reference manual for information if device supply pins are combined into one supply pin for certain packages and which supply pins are combined together. an off-chip decoupling capacitor (100 nf...220 nf, x7r ceramic) between the combined supply pin pair can improve the quality of this supply. 10.2.7 vdd ?internal regulator output supply (core logic) node vdd is a device internal supply output of the voltage regulator that provides the power supply for the core logic. this supply domain is monitored by the low voltage reset circuit. 10.2.8 vddf ?internal regulator output supply (nvm logic) node vddf is a device internal supply output of the voltage regulator that provides the power supply for the nvm logic. this supply domain is monitored by the low voltage reset circuit 10.2.9 api_extclk api external clock output pin this pin provides the signal selected via apies and is enabled with apiea bit. see device speci?ation to which pin it connects.
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 freescale semiconductor 371 10.3 memory map and registers this section provides a detailed description of all registers accessible in the s12cpmu. 10.3.1 module memory map the s12cpmu registers are shown in figure 10-3 . addres s name bit 7 6 5 4 3 2 1 bit 0 0x0034 cpmu synr r vcofrq[1:0] syndiv[5:0] w 0x0035 cpmu refdiv r reffrq[1:0] 00 refdiv[3:0] w 0x0036 cpmu postdiv r0 0 0 postdiv[4:0] w 0x0037 cpmuflg r rtif porf lvrf lockif lock ilaf oscif uposc w 0x0038 cpmuint r rtie 00 lockie 00 oscie 0 w 0x0039 cpmuclks r pllsel pstp 0 cop oscsel1 pre pce rti oscsel cop oscsel0 w 0x003a cpmupll r0 0 fm1 fm0 00 0 0 w 0x003b cpmurti r rtdec rtr6 rtr5 rtr4 rtr3 rtr2 rtr1 rtr0 w 0x003c cpmucop r wcop rsbck 000 cr2 cr1 cr0 w wrtmask 0x003d reservedcp mutest0 r0 0 0 000 0 0 w 0x003e reservedcp mutest1 r0 0 0 000 0 0 w 0x003f cpmu armcop r0 0 0 000 0 0 w bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x02f0 reserved r0 0 0 000 0 0 w 0x02f1 cpmu lvctl r 0 0 0 0 0 lvds lvie lvif w 0x02f2 cpmu apictl r apiclk 00 apies apiea apife apie apif w = unimplemented or reserved figure 10-3. cpmu register summary
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 372 freescale semiconductor 0x02f3 cpmuaclktr r aclktr5 aclktr4 aclktr3 aclktr2 aclktr1 aclktr0 00 w 0x02f4 cpmuapirh r apir15 apir14 apir13 apir12 apir11 apir10 apir9 apir8 w 0x02f5 cpmuapirl r apir7 apir6 apir5 apir4 apir3 apir2 apir1 apir0 w 0x02f6 reservedcp mutest3 r0 0 0 000 0 0 w 0x02f7 reserved r0 0 0 000 0 0 w 0x02f8 cpmu irctrimh r tctrim[4:0] 0 irctrim[9:8] w 0x02f9 cpmu irctriml r irctrim[7:0] w 0x02fa cpmuosc r osce reserved oscpins_ en reserved w 0x02fb cpmuprot r0 0 0 000 0 prot w 0x02fc reservedcp mutest2 r0 0 0 000 0 0 w addres s name bit 7 6 5 4 3 2 1 bit 0 = unimplemented or reserved figure 10-3. cpmu register summary
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 freescale semiconductor 373 10.3.2 register descriptions this section describes all the s12cpmu registers and their individual bits. address order is as listed in figure 10-3 . 10.3.2.1 s12cpmu synthesizer register (cpmusynr) the cpmusynr register controls the multiplication factor of the pll and selects the vco frequency range. read: anytime write: anytime if prot=0 (cpmuprot register) and pllsel=1 (cpmuclks register). else write has no effect. note writing to this register clears the lock and uposc status bits. note f vco must be within the speci?d vco frequency lock range. bus frequency f bus must not exceed the speci?d maximum. the vcofrq[1:0] bits are used to con?ure the vco gain for optimal stability and lock time. for correct pll operation the vcofrq[1:0] bits have to be selected according to the actual target vcoclk frequency as shown in table 10-1 . setting the vcofrq[1:0] bits incorrectly can result in a non functional pll (no locking and/or insuf?ient stability). 0x0034 76543210 r vcofrq[1:0] syndiv[5:0] w reset 01011000 figure 10-4. s12cpmu synthesizer register (cpmusynr) table 10-1. vco clock frequency selection vcoclk frequency ranges vcofrq[1:0] 32mhz <= f vco <= 48mhz 00 48mhz < f vco <= 50mhz 01 reserved 10 reserved 11 f vco 2f ref syndiv 1 + () = if pll has locked (lock=1)
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 374 freescale semiconductor 10.3.2.2 s12cpmu reference divider register (cpmurefdiv) the cpmurefdiv register provides a ?er granularity for the pll multiplier steps when using the external oscillator as reference. read: anytime write: anytime if prot=0 (cpmuprot register) and pllsel=1 (cpmuclks register). else write has no effect. note write to this register clears the lock and uposc status bits. the reffrq[1:0] bits are used to con?ure the internal pll ?ter for optimal stability and lock time. for correct pll operation the reffrq[1:0] bits have to be selected according to the actual refclk frequency as shown in table 10-2 . if irc1m is selected as refclk (osce=0) the pll ?ter is ?ed con?ured for the 1mhz <= f ref <= 2mhz range. the bits can still be written but will have no effect on the pll ?ter con?uration. for osce=1, setting the reffrq[1:0] bits incorrectly can result in a non functional pll (no locking and/or insuf?ient stability). 0x0035 76543210 r reffrq[1:0] 00 refdiv[3:0] w reset 00001111 figure 10-5. s12cpmu reference divider register (cpmurefdiv) table 10-2. reference clock frequency selection if osc_lcp is enabled refclk frequency ranges (osce=1) reffrq[1:0] 1mhz <= f ref <= 2mhz 00 2mhz < f ref <= 6mhz 01 6mhz < f ref <= 12mhz 10 f ref >12mhz 11 f ref f osc refdiv 1 + () ------------------------------------ = if xosclcp is enabled (osce=1) if xosclcp is disabled (osce=0) f ref f irc1m =
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 freescale semiconductor 375 10.3.2.3 s12cpmu post divider register (cpmupostdiv) the postdiv register controls the frequency ratio between the vcoclk and the pllclk. read: anytime write: anytime if pllsel=1. else write has no effect. 10.3.2.4 s12cpmu flags register (cpmuflg) this register provides s12cpmu status bits and ?gs. read: anytime write: refer to each bit for individual write conditions 0x0036 76543210 r000 postdiv[4:0] w reset 00000011 = unimplemented or reserved figure 10-6. s12cpmu post divider register (cpmupostdiv) 0x0037 76543210 r rtif porf lvrf lockif lock ilaf oscif uposc w reset 0 note 1 note 2 0 0 note 3 0 0 1. porf is set to 1 when a power on reset occurs. unaffected by system reset. 2. lvrf is set to 1 when a low voltage reset occurs. unaffected by system reset. set by power on reset. 3. ilaf is set to 1 when an illegal address reset occurs. unaffected by system reset. cleared by power on reset. = unimplemented or reserved figure 10-7. s12cpmu flags register (cpmuflg) f pll f vco postdiv 1 + () ---------------------------------------- - = if pll is locked (lock=1) if pll is not locked (lock=0) f pll f vco 4 --------------- = f bus f pll 2 ------------ - = if pll is selected (pllsel=1)
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 376 freescale semiconductor table 10-3. cpmuflg field descriptions field description 7 rtif real time interrupt flag rtif is set to 1 at the end of the rti period. this ?g can only be cleared by writing a 1. writing a 0 has no effect. if enabled (rtie=1), rtif causes an interrupt request. 0 rti time-out has not yet occurred. 1 rti time-out has occurred. 6 porf power on reset flag porf is set to 1 when a power on reset occurs. this ?g can only be cleared by writing a 1. writing a 0 has no effect. 0 power on reset has not occurred. 1 power on reset has occurred. 5 lvrf low voltage reset flag lvrf is set to 1 when a low voltage reset occurs. this ?g can only be cleared by writing a 1. writing a 0 has no effect. 0 low voltage reset has not occurred. 1 low voltage reset has occurred. 4 lockif pll lock interrupt flag lockif is set to 1 when lock status bit changes. this ?g can only be cleared by writing a 1. writing a 0 has no effect.if enabled (lockie=1), lockif causes an interrupt request. 0 no change in lock bit. 1 lock bit has changed. 3 lock lock status bit lock re?cts the current state of pll lock condition. writes have no effect. while pll is unlocked (lock=0) fpll is fvco / 4 to protect the system from high core clock frequencies during the pll stabilization time tlock. 0 vcoclk is not within the desired tolerance of the target frequency. f pll = f vco /4. 1 vcoclk is within the desired tolerance of the target frequency. f pll = f vco /(postdiv+1). 2 ilaf illegal address reset flag ilaf is set to 1 when an illegal address reset occurs. refer to mmc chapter for details. this ?g can only be cleared by writing a 1. writing a 0 has no effect. 0 illegal address reset has not occurred. 1 illegal address reset has occurred. 1 oscif oscillator interrupt flag oscif is set to 1 when uposc status bit changes. this ?g can only be cleared by writing a 1. writing a 0 has no effect.if enabled (oscie=1), oscif causes an interrupt request. 0 no change in uposc bit. 1 uposc bit has changed. 0 uposc oscillator status bit uposc re?cts the status of the oscillator. writes have no effect. while uposc=0 the oscclk going to the mscan module is off. entering full stop mode uposc is cleared. 0 the oscillator is off or oscillation is not quali?d by the pll. 1 the oscillator is quali?d by the pll.
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 freescale semiconductor 377 10.3.2.5 s12cpmu interrupt enable register (cpmuint) this register enables s12cpmu interrupt requests. read: anytime write: anytime 0x0038 76543210 r rtie 00 lockie 00 oscie 0 w reset 00000000 = unimplemented or reserved figure 10-8. s12cpmu interrupt enable register (cpmuint) table 10-4. cpmuint field descriptions field description 7 rtie real time interrupt enable bit 0 interrupt requests from rti are disabled. 1 interrupt will be requested whenever rtif is set. 4 lockie pll lock interrupt enable bit 0 pll lock interrupt requests are disabled. 1 interrupt will be requested whenever lockif is set. 1 oscie oscillator corrupt interrupt enable bit 0 oscillator corrupt interrupt requests are disabled. 1 interrupt will be requested whenever oscif is set.
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 378 freescale semiconductor 10.3.2.6 s12cpmu clock select register (cpmuclks) this register controls s12cpmu clock selection. read: anytime write: 1. only possible if prot=0 (cpmuprot register) in all mcu modes (normal and special mode). 2. all bits in special mode (if prot=0). 3. pllsel, pstp, pre, pce, rtioscsel: in normal mode (if prot=0). 4. coposcsel0: in normal mode (if prot=0) until cpmucop write once has taken place. if coposcsel0 was cleared by uposc=0 (entering full stop mode with coposcsel0=1 or insuf?ient oscclk quality), then coposcsel0 can be set once again. 5. coposcsel1: in normal mode (if prot=0) until cpmucop write once is taken. coposcsel1 will not be cleared by uposc=0 (entering full stop mode with coposcsel1=1 or insuf?ient oscclk quality if oscclk is used as clock source for other clock domains: for instance core clock etc.). note after writing cpmuclks register, it is strongly recommended to read back cpmuclks register to make sure that write of pllsel, rtioscsel, coposcsel0 and coposcsel1 was successful. 0x0039 76543210 r pllsel pstp 0 cop oscsel1 pre pce rti oscsel cop oscsel0 w reset 10000000 = unimplemented or reserved figure 10-9. s12cpmu clock select register (cpmuclks)
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 freescale semiconductor 379 table 10-5. cpmuclks descriptions field description 7 pllsel pll select bit this bit selects the pllclk as source of the system clocks (core clock and bus clock). pllsel can only be set to 0, if uposc=1. uposc= 0 sets the pllsel bit. entering full stop mode sets the pllsel bit. 0 system clocks are derived from oscclk if oscillator is up (uposc=1, f bus = f osc / 2. 1 system clocks are derived from pllclk, f bus = f pll / 2. 6 pstp pseudo stop bit this bit controls the functionality of the oscillator during stop mode. 0 oscillator is disabled in stop mode (full stop mode). 1 oscillator continues to run in stop mode (pseudo stop mode), option to run rti and cop. note: pseudo stop mode allows for faster stop recovery and reduces the mechanical stress and aging of the resonator in case of frequent stop conditions at the expense of a slightly increased power consumption. note: when starting up the external oscillator (either by programming osce bit to 1 or on exit from full stop mode with osce bit is already 1) the software must wait for a minimum time equivalent to the startup-time of the external oscillator t uposc before entering pseudo stop mode. 4 cop oscsel1 cop clock select 1 ?coposcsel0 and coposcsel1 combined determine the clock source to the cop (see also table 10-6 ). if coposcsel1 = 1, coposcsel0 has no effect regarding clock select and changing the coposcsel0 bit does not re-start the cop time-out period. coposcsel1 selects the clock source to the cop to be either aclk (derived from trimmable internal rc-oscillator) or clock selected via coposcsel0 (ircclk or oscclk ) . changing the coposcsel1 bit re-starts the cop time-out period. coposcsel1 can be set independent from value of uposc. uposc= 0 does not clear the coposcsel1 bit. 0 cop clock source de?ed by coposcsel0 1 cop clock source is aclk derived from a trimmable internal rc-oscillator 3 pre rti enable during pseudo stop bit ?pre enables the rti during pseudo stop mode. 0 rti stops running during pseudo stop mode. 1 rti continues running during pseudo stop mode if rtioscsel=1. note: if pre=0 or rtioscsel=0 then the rti will go static while stop mode is active. the rti counter will not be reset. 2 pce cop enable during pseudo stop bit ?pce enables the cop during pseudo stop mode. 0 cop stops running during pseudo stop mode if: coposcsel1=0 and coposcsel0=0 1 cop continues running during pseudo stop mode if: pstp=1, coposcsel1=0 and coposcsel0=1 note: if pce=0 or coposcsel0=0 while coposcsel1=0 then the cop is static during stop mode being active. the cop counter will not be reset.
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 380 freescale semiconductor table 10-6. coposcsel1, coposcsel0 clock source select description 1 rtioscsel rti clock select rtioscsel selects the clock source to the rti. either ircclk or oscclk. changing the rtioscsel bit re-starts the rti time-out period. rtioscsel can only be set to 1, if uposc=1. uposc= 0 clears the rtioscsel bit. 0 rti clock source is ircclk. 1 rti clock source is oscclk. 0 cop oscsel0 cop clock select 0 ?coposcsel0 and coposcsel1 combined determine the clock source to the cop (see also table 10-6 ) if coposcsel1 = 1, coposcsel0 has no effect regarding clock select and changing the coposcsel0 bit does not re-start the cop time-out period. when coposcsel1=0,coposcsel0 selects the clock source to the cop to be either ircclk or oscclk. changing the coposcsel0 bit re-starts the cop time-out period. coposcsel0 can only be set to 1, if uposc=1. uposc= 0 clears the coposcsel0 bit. 0 cop clock source is ircclk. 1 cop clock source is oscclk coposcsel1 coposcsel0 cop clock source 0 0 ircclk 0 1 oscclk 1 x aclk table 10-5. cpmuclks descriptions (continued) field description
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 freescale semiconductor 381 10.3.2.7 s12cpmu pll control register (cpmupll) this register controls the pll functionality. read: anytime write: anytime if prot=0 (cpmuprot register) and pllsel=1 (cpmuclks register). else write has no effect. note write to this register clears the lock and uposc status bits. note care should be taken to ensure that the bus frequency does not exceed the speci?d maximum when frequency modulation is enabled. 0x003a 76543210 r0 0 fm1 fm0 0000 w reset 00000000 figure 10-10. s12cpmu pll control register (cpmupll) table 10-7. cpmupll field descriptions field description 5, 4 fm1, fm0 pll frequency modulation enable bits fm1 and fm0 enable frequency modulation on the vcoclk. this is to reduce noise emission. the modulation frequency is f ref divided by 16. see table 10-8 for coding. table 10-8. fm amplitude selection fm1 fm0 fm amplitude / f vco variation 0 0 fm off 01 1% 10 2% 11 4%
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 382 freescale semiconductor 10.3.2.8 s12cpmu rti control register (cpmurti) this register selects the time-out period for the real time interrupt. the clock source for the rti is either ircclk or oscclk depending on the setting of the rtioscsel bit. in stop mode with pstp=1 (pseudo stop mode) and rtioscsel=1 the rti continues to run, else the rti counter halts in stop mode. read: anytime write: anytime note a write to this register starts the rti time-out period. a change of the rtioscsel bit (writing a different value or loosing uposc status) re-starts the rti time-out period. 0x003b 76543210 r rtdec rtr6 rtr5 rtr4 rtr3 rtr2 rtr1 rtr0 w reset 00000000 figure 10-11. s12cpmu rti control register (cpmurti) table 10-9. cpmurti field descriptions field description 7 rtdec decimal or binary divider select bit ?rtdec selects decimal or binary based prescaler values. 0 binary based divider value. see table 10-10 1 decimal based divider value. see table 10-11 6? rtr[6:4] real time interrupt prescale rate select bits ?these bits select the prescale rate for the rti. see table 10-10 and table 10-11 . 3? rtr[3:0] real time interrupt modulus counter select bits ?these bits select the modulus counter target value to provide additional granularity. table 10-10 and table 10-11 show all possible divide values selectable by the cpmurti register .
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 freescale semiconductor 383 table 10-10. rti frequency divide rates for rtdec = 0 rtr[3:0] rtr[6:4] = 000 (off) 001 (2 10 ) 010 (2 11 ) 011 (2 12 ) 100 (2 13 ) 101 (2 14 ) 110 (2 15 ) 111 (2 16 ) 0000 ( 1) off 1 1 denotes the default value out of reset.this value should be used to disable the rti to ensure future backwards compatibility. 2 10 2 11 2 12 2 13 2 14 2 15 2 16 0001 ( 2) off 2x2 10 2x2 11 2x2 12 2x2 13 2x2 14 2x2 15 2x2 16 0010 ( 3) off 3x2 10 3x2 11 3x2 12 3x2 13 3x2 14 3x2 15 3x2 16 0011 ( 4) off 4x2 10 4x2 11 4x2 12 4x2 13 4x2 14 4x2 15 4x2 16 0100 ( 5) off 5x2 10 5x2 11 5x2 12 5x2 13 5x2 14 5x2 15 5x2 16 0101 ( 6) off 6x2 10 6x2 11 6x2 12 6x2 13 6x2 14 6x2 15 6x2 16 0110 ( 7) off 7x2 10 7x2 11 7x2 12 7x2 13 7x2 14 7x2 15 7x2 16 0111 ( 8) off 8x2 10 8x2 11 8x2 12 8x2 13 8x2 14 8x2 15 8x2 16 1000 ( 9) off 9x2 10 9x2 11 9x2 12 9x2 13 9x2 14 9x2 15 9x2 16 1001 ( 10) off 10x2 10 10x2 11 10x2 12 10x2 13 10x2 14 10x2 15 10x2 16 1010 ( 11) off 11x2 10 11x2 11 11x2 12 11x2 13 11x2 14 11x2 15 11x2 16 1011 ( 12) off 12x2 10 12x2 11 12x2 12 12x2 13 12x2 14 12x2 15 12x2 16 1100 ( 13) off 13x2 10 13x2 11 13x2 12 13x2 13 13x2 14 13x2 15 13x2 16 1101 ( 14) off 14x2 10 14x2 11 14x2 12 14x2 13 14x2 14 14x2 15 14x2 16 1110 ( 15) off 15x2 10 15x2 11 15x2 12 15x2 13 15x2 14 15x2 15 15x2 16 1111 ( 16) off 16x2 10 16x2 11 16x2 12 16x2 13 16x2 14 16x2 15 16x2 16
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 384 freescale semiconductor table 10-11. rti frequency divide rates for rtdec=1 rtr[3:0] rtr[6:4] = 000 (1x10 3 ) 001 (2x10 3 ) 010 (5x10 3 ) 011 (10x10 3 ) 100 (20x10 3 ) 101 (50x10 3 ) 110 (100x10 3 ) 111 (200x10 3 ) 0000 ( 1) 1x10 3 2x10 3 5x10 3 10x10 3 20x10 3 50x10 3 100x10 3 200x10 3 0001 ( 2) 2x10 3 4x10 3 10x10 3 20x10 3 40x10 3 100x10 3 200x10 3 400x10 3 0010 ( 3) 3x10 3 6x10 3 15x10 3 30x10 3 60x10 3 150x10 3 300x10 3 600x10 3 0011 ( 4) 4x10 3 8x10 3 20x10 3 40x10 3 80x10 3 200x10 3 400x10 3 800x10 3 0100 ( 5) 5x10 3 10x10 3 25x10 3 50x10 3 100x10 3 250x10 3 500x10 3 1x10 6 0101 ( 6) 6x10 3 12x10 3 30x10 3 60x10 3 120x10 3 300x10 3 600x10 3 1.2x10 6 0110 ( 7) 7x10 3 14x10 3 35x10 3 70x10 3 140x10 3 350x10 3 700x10 3 1.4x10 6 0111 ( 8) 8x10 3 16x10 3 40x10 3 80x10 3 160x10 3 400x10 3 800x10 3 1.6x10 6 1000 ( 9) 9x10 3 18x10 3 45x10 3 90x10 3 180x10 3 450x10 3 900x10 3 1.8x10 6 1001 ( 10) 10 x10 3 20x10 3 50x10 3 100x10 3 200x10 3 500x10 3 1x10 6 2x10 6 1010 ( 11) 11 x10 3 22x10 3 55x10 3 110x10 3 220x10 3 550x10 3 1.1x10 6 2.2x10 6 1011 ( 12) 12x10 3 24x10 3 60x10 3 120x10 3 240x10 3 600x10 3 1.2x10 6 2.4x10 6 1100 ( 13) 13x10 3 26x10 3 65x10 3 130x10 3 260x10 3 650x10 3 1.3x10 6 2.6x10 6 1101 ( 14) 14x10 3 28x10 3 70x10 3 140x10 3 280x10 3 700x10 3 1.4x10 6 2.8x10 6 1110 ( 15) 15x10 3 30x10 3 75x10 3 150x10 3 300x10 3 750x10 3 1.5x10 6 3x10 6 1111 ( 16) 16x10 3 32x10 3 80x10 3 160x10 3 320x10 3 800x10 3 1.6x10 6 3.2x10 6
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 freescale semiconductor 385 10.3.2.9 s12cpmu cop control register (cpmucop) this register controls the cop (computer operating properly) watchdog. the clock source for the cop is either aclk, ircclk or oscclk depending on the setting of the coposcsel0 and coposcsel1 bit (see also table 10-6 ). in stop mode with pstp=1 (pseudo stop mode), coposcsel0=1 and coposcel1=0 and pce=1 the cop continues to run, else the cop counter halts in stop mode with coposcsel1 =0. in full stop mode and pseudo stop mode with coposcsel1=1 the cop continues to run. read: anytime write: 1. rsbck: anytime in special mode; write to ??but not to ??in normal mode 2. wcop, cr2, cr1, cr0: anytime in special mode, when wrtmask is 0, otherwise it has no effect write once in normal mode, when wrtmask is 0, otherwise it has no effect. writing cr[2:0] to ?00?has no effect, but counts for the ?rite once?condition. writing wcop to ??has no effect, but counts for the ?rite once?condition. when a non-zero value is loaded from flash to cr[2:0] the cop time-out period is started. a change of the coposcsel0 or copsocsel1 bit (writing a different value) or loosing uposc status while coposcsel1 is clear and coposcsel0 is set, re-starts the cop time-out period. in normal mode the cop time-out period is restarted if either of these conditions is true: 1. writing a non-zero value to cr[2:0] (anytime in special mode, once in normal mode) with wrtmask = 0. 2. writing wcop bit (anytime in special mode, once in normal mode) with wrtmask = 0. 3. changing rsbck bit from ??to ?? in special mode, any write access to cpmucop register restarts the cop time-out period. 0x003c 76543210 r wcop rsbck 000 cr2 cr1 cr0 w wrtmask reset f 0 0 0 0 f f f after de-assert of system reset the values are automatically loaded from the flash memory. see device specification for details. = unimplemented or reserved figure 10-12. s12cpmu cop control register (cpmucop)
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 386 freescale semiconductor table 10-12. cpmucop field descriptions field description 7 wcop window cop mode bit when set, a write to the cpmuarmcop register must occur in the last 25% of the selected period. a write during the ?st 75% of the selected period generates a cop reset. as long as all writes occur during this window, $55 can be written as often as desired. once $aa is written after the $55, the time-out logic restarts and the user must wait until the next window before writing to cpmuarmcop. table 10-13 shows the duration of this window for the seven available cop rates. 0 normal cop operation 1 window cop operation 6 rsbck cop and rti stop in active bdm mode bit 0 allows the cop and rti to keep running in active bdm mode. 1 stops the cop and rti counters whenever the part is in active bdm mode. 5 wrtmask write mask for wcop and cr[2:0] bit this write-only bit serves as a mask for the wcop and cr[2:0] bits while writing the cpmucop register. it is intended for bdm writing the rsbck without changing the content of wcop and cr[2:0]. 0 write of wcop and cr[2:0] has an effect with this write of cpmucop 1 write of wcop and cr[2:0] has no effect with this write of cpmucop. (does not count for ?rite once?) 2? cr[2:0] cop watchdog timer rate select ?these bits select the cop time-out rate (see table 10-13 and table 10-14 ). writing a nonzero value to cr[2:0] enables the cop counter and starts the time-out period. a cop counter time-out causes a system reset. this can be avoided by periodically (before time-out) initializing the cop counter via the cpmuarmcop register. while all of the following four conditions are true the cr[2:0], wcop bits are ignored and the cop operates at highest time-out period ( 2 24 cycles) in normal cop mode (window cop mode disabled): 1) cop is enabled (cr[2:0] is not 000) 2) bdm mode active 3) rsbck = 0 4) operation in special mode table 10-13. cop watchdog rates if coposcsel1=0 (default out of reset) cr2 cr1 cr0 copclk cycles to time-out (copclk is either ircclk or oscclk depending on the coposcsel0 bit) 0 0 0 cop disabled 001 2 14 010 2 16 011 2 18 100 2 20 101 2 22 110 2 23 111 2 24
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 freescale semiconductor 387 table 10-14. cop watchdog rates if coposcsel1=1 cr2 cr1 cr0 copclk cycles to time-out (copclk is aclk - internal rc-oscillator clock) 0 0 0 cop disabled 001 2 7 010 2 9 011 2 11 100 2 13 101 2 15 110 2 16 111 2 17
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 388 freescale semiconductor 10.3.2.10 reserved register cpmutest0 note this reserved register is designed for factory test purposes only, and is not intended for general user access. writing to this register when in special mode can alter the s12cpmus functionality. read: anytime write: only in special mode 10.3.2.11 reserved register cpmutest1 note this reserved register is designed for factory test purposes only, and is not intended for general user access. writing to this register when in special mode can alter the s12cpmus functionality. read: anytime write: only in special mode 0x003d 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 10-13. reserved register (cpmutest0) 0x003e 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 10-14. reserved register (cpmutest1)
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 freescale semiconductor 389 10.3.2.12 s12cpmu cop timer arm/reset register (cpmuarmcop) this register is used to restart the cop time-out period. read: always reads $00 write: anytime when the cop is disabled (cr[2:0] = ?00? writing to this register has no effect. when the cop is enabled by setting cr[2:0] nonzero, the following applies: writing any value other than $55 or $aa causes a cop reset. to restart the cop time-out period write $55 followed by a write of $aa. these writes do not need to occur back-to-back, but the sequence ($55, $aa) must be completed prior to cop end of time-out period to avoid a cop reset. sequences of $55 writes are allowed. when the wcop bit is set, $55 and $aa writes must be done in the last 25% of the selected time-out period; writing any value in the ?st 75% of the selected period will cause a cop reset. 0x003f 76543210 r00000000 w armcop-bit 7 armcop-bit 6 armcop-bit 5 armcop-bit 4 armcop-bit 3 armcop-bit 2 armcop-bit 1 armcop-bit 0 reset 00000000 figure 10-15. s12cpmu cpmuarmcop register
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 390 freescale semiconductor 10.3.2.13 low voltage control register (cpmulvctl) the cpmulvctl register allows the con?uration of the low-voltage detect features. read: anytime write: lvie and lvif are write anytime, lvds is read only 0x02f1 76543210 r00000lvds lvie lvif w reset 00000u0u the reset state of lvds and lvif depends on the external supplied vdda level = unimplemented or reserved figure 10-16. low voltage control register (cpmulvctl) table 10-15. cpmulvctl field descriptions field description 2 lvds low-voltage detect status bit this read-only status bit re?cts the voltage level on vdda. writes have no effect. 0 input voltage vdda is above level v lvid or rpm. 1 input voltage vdda is below level v lvia and fpm. 1 lvie low-voltage interrupt enable bit 0 interrupt request is disabled. 1 interrupt will be requested whenever lvif is set. 0 lvif low-voltage interrupt flag lvif is set to 1 when lvds status bit changes. this ?g can only be cleared by writing a 1. writing a 0 has no effect. if enabled (lvie = 1), lvif causes an interrupt request. 0 no change in lvds bit. 1 lvds bit has changed.
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 freescale semiconductor 391 10.3.2.14 autonomous periodical interrupt control register (cpmuapictl) the cpmuapictl register allows the con?uration of the autonomous periodical interrupt features. read: anytime write: anytime 0x02f2 76543210 r apiclk 00 apies apiea apife apie apif w reset 00000000 = unimplemented or reserved figure 10-17. autonomous periodical interrupt control register (cpmuapictl) table 10-16. cpmuapictl field descriptions field description 7 apiclk autonomous periodical interrupt clock select bit ?selects the clock source for the api. writable only if apife = 0. apiclk cannot be changed if apife is set by the same write operation. 0 autonomous clock (aclk) used as source. 1 bus clock used as source. 4 apies autonomous periodical interrupt external select bit ?selects the waveform at the external pin api_extclk as shown in figure 10-18 . see device level speci?ation for connectivity of api_extclk pin. 0 if apiea and apife are set, at the external pin api_extclk periodic high pulses are visible at the end of every selected period with the size of half of the minimum period (apir=0x0000 in table 10-20 ). 1 if apiea and apife are set, at the external pin api_extclk a clock is visible with 2 times the selected api period. 3 apiea autonomous periodical interrupt external access enable bit if set, the waveform selected by bit apies can be accessed externally. see device level speci?ation for connectivity. 0 waveform selected by apies can not be accessed externally. 1 waveform selected by apies can be accessed externally, if apife is set. 2 apife autonomous periodical interrupt feature enable bit ?enables the api feature and starts the api timer when set. 0 autonomous periodical interrupt is disabled. 1 autonomous periodical interrupt is enabled and timer starts running. 1 apie autonomous periodical interrupt enable bit 0 api interrupt request is disabled. 1 api interrupt will be requested whenever apif is set. 0 apif autonomous periodical interrupt flag ?after each time-out of the api (time-out rate is con?ured in the cpmuapirh/l registers) the interrupt ?g apif is set to 1. this ?g can only be cleared by writing a 1. writing a 0 has no effect. if enabled (apie = 1), apif causes an interrupt request. 0 api time-out has not yet occurred. 1 api time-out has occurred.
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 392 freescale semiconductor figure 10-18. waveform selected on api_extclk pin (apiea=1, apife=1) apies=0 apies=1 api period api min. period / 2
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 freescale semiconductor 393 10.3.2.15 autonomous clock trimming register (cpmuaclktr) the cpmuaclktr register con?ures the trimming of the autonomous clock (aclk - trimmable internal rc-oscillator) which can be selected as clock source for some cpmu features . read: anytime write: anytime 0x02f3 76543210 r aclktr5 aclktr4 aclktr3 aclktr2 aclktr1 aclktr0 00 w reset f f ffff00 after de-assert of system reset a value is automatically loaded from the flash memory. figure 10-19. autonomous periodical interrupt trimming register (cpmuaclktr) table 10-17. cpmuaclktr field descriptions field description 7? aclktr[5:0] autonomous clock trimming bits ?see table 10-18 for trimming effects. the aclktr[5:0] value represents a signed number in?encing the aclk period time. table 10-18. trimming effect of aclktr bit trimming effect aclktr[5] increases period aclktr[4] decreases period less than aclktr[5] increased it aclktr[3] decreases period less than aclktr[4] aclktr[2] decreases period less than aclktr[3] aclktr[1] decreases period less than aclktr[2] aclktr[0] decreases period less than aclktr[1]
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 394 freescale semiconductor 10.3.2.16 autonomous periodical interrupt rate high and low register (cpmuapirh / cpmuapirl) the cpmuapirh and cpmuapirl registers allow the con?uration of the autonomous periodical interrupt rate . read: anytime write: anytime if apife=0. else writes have no effect. the period can be calculated as follows depending on logical value of the apiclk bit: apiclk=0: period = 2*(apir[15:0] + 1) * f aclk apiclk=1: period = 2*(apir[15:0] + 1) * bus clock period note for apiclk bit clear the ?st time-out period of the api will show a latency time between two to three f aclk cycles due to synchronous clock gate release when the api feature gets enabled (apife bit set) . 0x02f4 76543210 r apir15 apir14 apir13 apir12 apir11 apir10 apir9 apir8 w reset 00000000 = unimplemented or reserved figure 10-20. autonomous periodical interrupt rate high register (cpmuapirh) 0x02f5 76543210 r apir7 apir6 apir5 apir4 apir3 apir2 apir1 apir0 w reset 00000000 figure 10-21. autonomous periodical interrupt rate low register (cpmuapirl) table 10-19. cpmuapirh / cpmuapirl field descriptions field description 15-0 apir[15:0] autonomous periodical interrupt rate bits ?these bits de?e the time-out period of the api. see table 10-20 for details of the effect of the autonomous periodical interrupt rate bits.
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 freescale semiconductor 395 table 10-20. selectable autonomous periodical interrupt periods apiclk apir[15:0] selected period 0 0000 0.2 ms 1 1 when f aclk is trimmed to 10khz. 0 0001 0.4 ms 1 0 0002 0.6 ms 1 0 0003 0.8 ms 1 0 0004 1.0 ms 1 0 0005 1.2 ms 1 0 ..... ..... 0 fffd 13106.8 ms 1 0 fffe 13107.0 ms 1 0 ffff 13107.2 ms 1 1 0000 2 * bus clock period 1 0001 4 * bus clock period 1 0002 6 * bus clock period 1 0003 8 * bus clock period 1 0004 10 * bus clock period 1 0005 12 * bus clock period 1 ..... ..... 1 fffd 131068 * bus clock period 1 fffe 131070 * bus clock period 1 ffff 131072 * bus clock period
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 396 freescale semiconductor 10.3.2.17 reserved register cpmutest3 note this reserved register is designed for factory test purposes only, and is not intended for general user access. writing to this register when in special mode can alter the s12cpmus functionality. read: anytime write: only in special mode 0x02f6 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 10-22. reserved register (cpmutest3)
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 freescale semiconductor 397 10.3.2.18 s12cpmu irc1m trim registers (cpmuirctrimh / cpmuirctriml) read: anytime write: anytime if prot=0 (cpmuprot register). else write has no effect note writes to these registers while pllsel=1 clears the lock and uposc status bits. 0x02f8 15 14 13 12 11 10 9 8 r tctrim[4:0] 0 irctrim[9:8] w reset f f f f 0 0 f f after de-assert of system reset a factory programmed trim value is automatically loaded from the flash memory to provide trimmed internal reference frequency f irc1m_trim . figure 10-23. s12cpmu irc1m trim high register (cpmuirctrimh) 0x02f9 76543210 r irctrim[7:0] w reset f f ffffff after de-assert of system reset a factory programmed trim value is automatically loaded from the flash memory to provide trimmed internal reference frequency f irc1m_trim . figure 10-24. s12cpmu irc1m trim low register (cpmuirctriml) table 10-22. cpmuirctrimh/l field descriptions field description 15-11 tctrim[4:0] irc1m temperature coef?ient trim bits trim bits for the temperature coef?ient (tc) of the irc1m frequency. figure 10-26 shows the in?ence of the bits tctrim4:0] on the relationship between frequency and temperature. figure 10-26 shows an approximate tc variation, relative to the nominal tc of the irc1m (i.e. for tctrim[4:0]=0b00000 or 0b10000). 9-0 irctrim[9:0] irc1m frequency trim bits ?trim bits for internal reference clock after system reset the factory programmed trim value is automatically loaded into these registers, resulting in a internal reference frequency f irc1m_trim . see device electrical characteristics for value of f irc1m_trim . the frequency trimming consists of two different trimming methods: a rough trimming controlled by bits irctrim[9:6] can be done with frequency leaps of about 6% in average. a ?e trimming controlled by the bits irctrim[5:0] can be done with frequency leaps of about 0.3% (this trimming determines the precision of the frequency setting of 0.15%, i.e. 0.3% is the distance between two trimming values). figure 10-25 shows the relationship between the trim bits and the resulting irc1m frequency.
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 398 freescale semiconductor figure 10-25. irc1m frequency trimming diagram irctrim[9:0] $000 irctrim[9:6] irctrim[5:0] irc1m frequency (ircclk) 600khz 1.5mhz 1mhz $3ff { ......
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 freescale semiconductor 399 figure 10-26. in?ence of tctrim[4:0] on the temperature coef?ient note the frequency is not necessarily linear with the temperature (in most cases it will not be). the above diagram is meant only to give the direction (positive or negative) of the variation of the tc, relative to the nominal tc. setting tctrim[4:0] to 0b00000 or 0b10000 does not mean that the temperature coef?ient will be zero. these two combinations basically switch off the tc compensation module, which results in the nominal tc of the irc1m. frequency temperature tctrim[4:0] = 0b11111 tctrim[4:0] = 0b01111 - 40c 150c tctrim[4:0] = 0b10000 or 0b00000 (nominal tc) 0b00001 0b00010 0b00011 0b00100 0b00101 ... 0b01111 0b11111 ... 0b10101 0b10100 0b10011 0b10010 0b10001 tc increases tc decreases
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 400 freescale semiconductor table 10-23. tc trimming of the irc1m frequency at ambient temperature tctrim[4:0] irc1m indicative relative tc variation irc1m indicative frequency drift for relative tc variation 00000 0 (nominal tc of the irc) 0% 00001 -0.27% -0.5% 00010 -0.54% -0.9% 00011 -0.81% -1.3% 00100 -1.08% -1.7% 00101 -1.35% -2.0% 00110 -1.63% -2.2% 00111 -1.9% -2.5% 01000 -2.20% -3.0% 01001 -2.47% -3.4% 01010 -2.77% -3.9% 01011 -3.04 -4.3% 01100 -3.33% -4.7% 01101 -3.6% -5.1% 01110 -3.91% -5.6% 01111 -4.18% -5.9% 10000 0 (nominal tc of the irc) 0% 10001 +0.27% +0.5% 10010 +0.54% +0.9% 10011 +0.81% +1.3% 10100 +1.07% +1.7% 10101 +1.34% +2.0% 10110 +1.59% +2.2% 10111 +1.86% +2.5% 11000 +2.11% +3.0% 11001 +2.38% +3.4% 11010 +2.62% +3.9% 11011 +2.89% +4.3% 11100 +3.12% +4.7% 11101 +3.39% +5.1% 11110 +3.62% +5.6% 11111 +3.89% +5.9%
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 freescale semiconductor 401 note since the irc1m frequency is not a linear function of the temperature, but more like a parabola, the above relative variation is only an indication and should be considered with care. be aware that the output frequency vary with tc trimming. a frequency trimming correction is therefore necessary. the values provided in table 10-23 are typical values at ambient temperature which can vary from device to device. 10.3.2.19 s12cpmu oscillator register (cpmuosc) this registers con?ures the external oscillator (xosclcp). read: anytime write: anytime if prot=0 (cpmuprot register) and pllsel=1 (cpmuclks register). else write has no effect. note. write to this register clears the lock and uposc status bits. 0x02fa 76543210 r osce reserved oscpins_e n reserved] w reset 00000000 figure 10-27. s12cpmu oscillator register (cpmuosc)
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 402 freescale semiconductor table 10-24. cpmuosc field descriptions field description 7 osce oscillator enable bit ?this bit enables the external oscillator (xosclcp). the uposc status bit in the cpmuflg register indicates when the oscillation is stable and oscclk can be selected as bus clock or source of the cop or rti. a loss of oscillation will lead to a clock monitor reset. 0 external oscillator is disabled. refclk for pll is ircclk. 1 external oscillator is enabled.clock monitor is enabled.external oscillator is quali?d by pllclk refclk for pll is the external oscillator clock divided by refdiv. note: when starting up the external oscillator (either by programming osce bit to 1 or on exit from full stop mode with osce bit already 1) the software must wait for a minimum time equivalent to the startup-time of the external oscillator t uposc before entering pseudo stop mode. 6 reserved do not alter this bit from its reset value. it is for manufacturer use only and can change the pll behavior. 5 oscpins_en oscillator pins extal and xtal enable bit if osce=1 this read-only bit is set. it can only be cleared with the next reset. enabling the external oscillator reserves the extal and xtal pins exclusively for oscillator application. 0 extal and xtal pins are not reserved for oscillator. 1 extal and xtal pins exclusively reserved for oscillator. 4-0 reserved do not alter these bits from their reset value. it is for manufacturer use only and can change the pll behavior.
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 freescale semiconductor 403 10.3.2.20 s12cpmu protection register (cpmuprot) this register protects the following clock con?uration registers from accidental overwrite: cpmusynr, cpmurefdiv, cpmuclks, cpmupll, cpmuirctrimh/l and cpmuosc read: anytime write: anytime 0x02fb 76543210 r0000000 prot w reset 00000000 figure 10-28. s12cpmu protection register (cpmuprot) field description 0 prot clock con?uration registers protection bit ?this bit protects the clock con?uration registers from accidental overwrite (see list of affected registers above): writing 0x26 to the cpmuprot register clears the prot bit, other write accesses set the prot bit. 0 protection of clock con?uration registers is disabled. 1 protection of clock con?uration registers is enabled. (see list of protected registers above).
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 404 freescale semiconductor 10.3.2.21 reserved register cpmutest2 note this reserved register is designed for factory test purposes only, and is not intended for general user access. writing to this register when in special mode can alter the s12cpmus functionality. read: anytime write: only in special mode 0x02fc 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 10-29. reserved register cpmutest2
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 freescale semiconductor 405 10.4 functional description 10.4.1 phase locked loop with internal filter (pll) the pll is used to generate a high speed pllclk based on a low frequency refclk. the refclk is by default the ircclk which is trimmed to f irc1m_trim =1mhz. if using the oscillator (osce=1) refclk will be based on oscclk. for increased ?xibility, oscclk can be divided in a range of 1 to 16 to generate the reference frequency refclk using the refdiv[3:0] bits. based on the syndiv[5:0] bits the pll generates the vcoclk by multiplying the reference clock by a 2, 4, 6,... 126, 128. based on the postdiv[4:0] bits the vcoclk can be divided in a range of 1,2, 3, 4, 5, 6,... to 32 to generate the pllclk. . note although it is possible to set the dividers to command a very high clock frequency, do not exceed the speci?d bus frequency limit for the mcu. f vco 2f ref syndiv 1 + () = f ref f osc refdiv 1 + () ------------------------------------ = if oscillator is enabled (osce=1) if oscillator is disabled (osce=0) f ref f irc1m = f pll f vco postdiv 1 + () ---------------------------------------- - = if pll is locked (lock=1) if pll is not locked (lock=0) f pll f vco 4 --------------- = f bus f pll 2 ------------ - = if pll is selected (pllsel=1)
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 406 freescale semiconductor several examples of pll divider settings are shown in table 10-25 . the following rules help to achieve optimum stability and shortest lock time: use lowest possible f vco / f ref ratio (syndiv value). use highest possible refclk frequency f ref . the phase detector inside the pll compares the feedback clock (fbclk = vcoclk/(syndiv+1)) with the reference clock (refclk = (irc1m or oscclk)/(refdiv+1)). correction pulses are generated based on the phase difference between the two signals. the loop ?ter alters the dc voltage on the internal ?ter capacitor, based on the width and direction of the correction pulse, which leads to a higher or lower vco frequency. the user must select the range of the refclk frequency (reffrq[1:0] bits) and the range of the vcoclk frequency (vcofrq[1:0] bits) to ensure that the correct pll loop bandwidth is set. the lock detector compares the frequencies of the fbclk and the refclk. therefore the speed of the lock detector is directly proportional to the reference clock frequency. the circuit determines the lock condition based on this comparison. if pll lock interrupt requests are enabled, the software can wait for an interrupt request and for instance check the lock bit. if interrupt requests are disabled, software can poll the lock bit continuously (during pll start-up) or at periodic intervals. in either case, only when the lock bit is set, the vcoclk will have stabilized to the programmed frequency. the lock bit is a read-only indicator of the locked state of the pll. the lock bit is set when the vco frequency is within the tolerance ? lock and is cleared when the vco frequency is out of the tolerance ? unl . interrupt requests can occur if enabled (lockie = 1) when the lock condition changes, toggling the lock bit. table 10-25. examples of pll divider settings f osc refdiv[3: 0] f ref reffrq[1:0] syndiv[5:0] f vco vcofrq[1:0] postdiv [4:0] f pll f bus off $00 1mhz 00 $18 50mhz 01 $03 12.5mhz 6.25mhz off $00 1mhz 00 $18 50mhz 01 $00 50mhz 25mhz 4mhz $00 4mhz 01 $05 48mhz 00 $00 48mhz 24mhz
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 freescale semiconductor 407 10.4.2 startup from reset an example of startup of clock system from reset is given in figure 10-30 . figure 10-30. startup of clock system after reset 10.4.3 stop mode using pllclk as bus clock an example of what happens going into stop mode and exiting stop mode after an interrupt is shown in figure 10-31 . disable pll lock interrupt (lockie=0) before going into stop mode. figure 10-31. stop mode using pllclk as bus clock system pllclk reset f vcorst cpu reset state vector fetch, program execution lock postdiv $03 (default target f pll =f vco /4 = 12.5mhz) f pll increasing f pll =16mhz t lock syndiv $18 (default target f vco =50mhz) $01 f pll =32 mhz example change of postdiv 768 cycles ) ( pllclk cpu lock t lock stop instruction execution interrupt continue execution wakeup t stp_rec
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 408 freescale semiconductor 10.4.4 full stop mode using oscillator clock as bus clock an example of what happens going into full stop mode and exiting full stop mode after an interrupt is shown in figure 10-32 . disable pll lock interrupt (lockie=0) and oscillator status change interrupt (oscie=0) before going into full stop mode. figure 10-32. full stop mode using oscillator clock as bus clock cpu uposc t lock stop instruction execution interrupt continue execution wakeup t stp_rec core clock select oscclk as core/bus clock by writing pllsel to ? pllsel automatically set when going into full stop mode oscclk pllclk
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 freescale semiconductor 409 10.4.5 external oscillator 10.4.5.1 enabling the external oscillator an example of how to use the oscillator as bus clock is shown in figure 10-33 . figure 10-33. enabling the external oscillator pllsel osce extal oscclk core enable external oscillator by writing osce bit to one. crystal/resonator starts oscillating uposc uposc ?g is set upon successful start of oscillation select oscclk as core/bus clock by writing pllsel to zero clock based on pllclk based on oscclk
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 410 freescale semiconductor 10.4.6 system clock con?urations 10.4.6.1 pll engaged internal mode (pei) this mode is the default mode after system reset or power-on reset. the bus clock is based on the pllclk, the reference clock for the pll is internally generated (irc1m). the pll is con?ured to 50 mhz vcoclk with postdiv set to 0x03. if locked (lock=1) this results in a pllclk of 12.5 mhz and a bus clock of 6.25 mhz. the pll can be re-con?ured to other bus frequencies. the clock sources for cop and rti can be based on the internal reference clock generator (irc1m) or the rc-oscillator (aclk). 10.4.6.2 pll engaged external mode (pee) in this mode, the bus clock is based on the pllclk as well (like pei). the reference clock for the pll is based on the external oscillator. the clock sources for cop and rti can be based on the internal reference clock generator or on the external oscillator clock or the rc-oscillator (aclk). this mode can be entered from default mode pei by performing the following steps: 1. con?ure the pll for desired bus frequency. 2. enable the external oscillator (osce bit). 3. wait for oscillator to start-up and the pll being locked (lock = 1) and (uposc =1). 4. clear all ?gs in the cpmuflg register to be able to detect any future status bit change. 5. optionally status interrupts can be enabled (cpmuint register). loosing pll lock status (lock=0) means loosing the oscillator status information as well (uposc=0). the impact of loosing the oscillator status (uposc=0) in pee mode is as follows: the pllclk is derived from the vco clock (with its actual frequency) divided by four until the pll locks again. the oscclk provided to the mscan module is off. application software needs to be prepared to deal with the impact of loosing the oscillator status at any time. 10.4.6.3 pll bypassed external mode (pbe) in this mode, the bus clock is based on the external oscillator clock. the reference clock for the pll is based on the external oscillator. the clock sources for cop and rti can be based on the internal reference clock generator or on the external oscillator clock or the rc-oscillator (aclk).
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 freescale semiconductor 411 this mode can be entered from default mode pei by performing the following steps: 1. make sure the pll con?uration is valid. 2. enable the external oscillator (osce bit) 3. wait for the oscillator to start-up and the pll being locked (lock = 1) and (uposc =1). 4. clear all ?gs in the cpmuflg register to be able to detect any status bit change. 5. optionally status interrupts can be enabled (cpmuint register). 6. select the oscillator clock (oscclk) as bus clock (pllsel=0) loosing pll lock status (lock=0) means loosing the oscillator status information as well (uposc=0). the impact of loosing the oscillator status (uposc=0) in pbe mode is as follows: pllsel is set automatically and the bus clock is switched back to the pllclk. the pllclk is derived from the vco clock (with its actual frequency) divided by four until the pll locks again. the oscclk provided to the mscan module is off. application software needs to be prepared to deal with the impact of loosing the oscillator status at any time. 10.5 resets 10.5.1 general all reset sources are listed in table 10-26 . refer to mcu speci?ation for related vector addresses and priorities. 10.5.2 description of reset operation upon detection of any reset of table 10-26 , an internal circuit drives the reset pin low for 512 pllclk cycles. after 512 pllclk cycles the reset pin is released. the reset generator of the s12cpmu waits for additional 256 pllclk cycles and then samples the reset pin to determine the originating source. table 10-27 shows which vector will be fetched. table 10-26. reset summary reset source local enable power-on reset (por) none low voltage reset (lvr) none external pin reset none illegal address reset none clock monitor reset osce bit in cpmuosc register cop reset cr[2:0] in cpmucop register
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 412 freescale semiconductor note while system reset is asserted the pllclk runs with the frequency f vcorst . the internal reset of the mcu remains asserted while the reset generator completes the 768 pllclk cycles long reset sequence. in case the reset pin is externally driven low for more than these 768 pllclk cycles (external reset), the internal reset remains asserted longer. figure 10-34. reset timing 10.5.2.1 clock monitor reset if the external oscillator is enabled (osce=1) in case of loss of oscillation or the oscillator frequency is below the failure assert frequency f cmfa (see device electrical characteristics for values), the s12cpmu table 10-27. reset vector selection sampled reset pin (256 cycles after release) oscillator monitor fail pending cop time out pending vector fetch 1 0 0 por lv r illegal address reset external pin reset 1 1 x clock monitor reset 1 0 1 cop reset 0 x x por lv r illegal address reset external pin reset ) ( ) pllclk 512 cycles 256 cycles s12_cpmu drives possibly reset driven low externally ) ( ( reset s12_cpmu releases f vcorst reset pin low reset pin f vcorst
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 freescale semiconductor 413 generates a clock monitor reset.in full stop mode the external oscillator and the clock monitor are disabled. 10.5.2.2 computer operating properly watchdog (cop) reset the cop (free running watchdog timer) enables the user to check that a program is running and sequencing properly. when the cop is being used, software is responsible for keeping the cop from timing out. if the cop times out it is an indication that the software is no longer being executed in the intended sequence; thus cop reset is generated. the clock source for the cop is either aclk, ircclk or oscclk depending on the setting of the coposcsel0 and coposcsel1 bit. in stop mode with pstp=1 (pseudo stop mode), coposcsel0=1 and coposcel1=0 and pce=1 the cop continues to run, else the cop counter halts in stop mode with coposcsel1 =0. in pseudo stop mode and full stop mode with coposcsel1=1 the cop continues to run. table 10-28.gives an overview of the cop condition (run, static) in stop mode depending on legal con?uration and status bit settings: table 10-28. cop condition (run, static) in stop mode three control bits in the cpmucop register allow selection of seven cop time-out periods. when cop is enabled, the program must write $55 and $aa (in this order) to the cpmuarmcop register during the selected time-out period. once this is done, the cop time-out period is restarted. if the program fails to do this and the cop times out, a cop reset is generated. also, if any value other than $55 or $aa is written, a cop reset is generated. coposcsel1 pstp pce coposcsel0 osce uposc cop counter behavior in stop mode (clock source) 1 x x x x x run (aclk) 0 1 1 1 1 1 run (oscclk) 0 1 1 0 0 x static (ircclk) 0 1 1 0 1 x static (ircclk) 0 1 0 0 x x static (ircclk) 0 1 0 1 1 1 static (oscclk) 0 0 1 1 1 1 static (oscclk) 0 0 1 0 1 x static (ircclk) 0 0 1 0 0 0 static (ircclk) 0 0 0 1 1 1 satic (oscclk) 0 0 0 0 1 1 static (ircclk) 0 0 0 0 1 0 static (ircclk) 0 0 0 0 0 0 static (ircclk)
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 414 freescale semiconductor windowed cop operation is enabled by setting wcop in the cpmucop register. in this mode, writes to the cpmuarmcop register to clear the cop timer must occur in the last 25% of the selected time-out period. a premature write will immediately reset the part. 10.5.3 power-on reset (por) the on-chip por circuitry detects when the internal supply vdd drops below an appropriate voltage level. the por is deasserted, if the internal supply vdd exceeds an appropriate voltage level (voltage levels are not speci?d in this document because this internal supply is not visible on device pins). 10.5.4 low-voltage reset (lvr) the on-chip lvr circuitry detects when one of the supply voltages vdd, vddf or vddx drops below an appropriate voltage level. if lvr is deasserted the mcu is fully operational at the speci?d maximum speed. the lvr assert and deassert levels for the supply voltage vddx are v lvrxa and v lvrxd and are speci?d in the device reference manual. 10.6 interrupts the interrupt/reset vectors requested by the s12cpmu are listed in table 10-29 . refer to mcu speci?ation for related vector addresses and priorities. 10.6.1 description of interrupt operation 10.6.1.1 real time interrupt (rti) the clock source for the rti is either ircclk or oscclk depending on the setting of the rtioscsel bit. in stop mode with pstp=1 (pseudo stop mode), rtioscsel=1 and pre=1 the rti continues to run, else the rti counter halts in stop mode. table 10-29. s12cpmu interrupt vectors interrupt source ccr mask local enable rti time-out interrupt i bit cpmuint (rtie) pll lock interrupt i bit cpmuint (lockie) oscillator status interrupt i bit cpmuint (oscie) low voltage interrupt i bit cpmulvctl (lvie) autonomous periodical interrupt i bit cpmuapictl (apie)
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 freescale semiconductor 415 the rti can be used to generate hardware interrupts at a ?ed periodic rate. if enabled (by setting rtie=1), this interrupt will occur at the rate selected by the cpmurti register. at the end of the rti time-out period the rtif ?g is set to one and a new rti time-out period starts immediately. a write to the cpmurti register restarts the rti time-out period. 10.6.1.2 pll lock interrupt the s12cpmu generates a pll lock interrupt when the lock condition (lock status bit) of the pll changes, either from a locked state to an unlocked state or vice versa. lock interrupts are locally disabled by setting the lockie bit to zero. the pll lock interrupt ?g (lockif) is set to 1 when the lock condition has changed, and is cleared to 0 by writing a 1 to the lockif bit. 10.6.1.3 oscillator status interrupt when the osce bit is 0, then uposc stays 0. when osce = 1 the uposc bit is set after the lock bit is set. upon detection of a status change (uposc) the oscif ?g is set. going into full stop mode or disabling the oscillator can also cause a status change of uposc. any change in pll con?uration or any other event which causes the pll lock status to be cleared leads to a loss of the oscillator status information as well (uposc=0). oscillator status change interrupts are locally enabled with the oscie bit. note losing the oscillator status (uposc=0) affects the clock con?uration of the system 1 . this needs to be dealt with in application software. 10.6.1.4 low-voltage interrupt (lvi) in fpm the input voltage vdda is monitored. whenever vdda drops below level v lvia, the status bit lvds is set to 1. when vdda rises above level v lvid the status bit lvds is cleared to 0. an interrupt, indicated by ?g lvif = 1, is triggered by any change of the status bit lvds if interrupt enable bit lvie = 1. 10.6.1.5 autonomous periodical interrupt (api) the api sub-block can generate periodical interrupts independent of the clock source of the mcu. to enable the timer, the bit apife needs to be set. the api timer is either clocked by the autonomous clock (aclk - trimmable internal rc oscillator) or the bus clock. timer operation will freeze when mcu clock source is selected and bus clock is turned off. the clock source can be selected with bit apiclk. apiclk can only be written when apife is not set. 1. for details please refer to ?st-blue>10.4.6 system clock con?urations
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 416 freescale semiconductor the apir[15:0] bits determine the interrupt period. apir[15:0] can only be written when apife is cleared. as soon as apife is set, the timer starts running for the period selected by apir[15:0] bits. when the con?ured time has elapsed, the ?g apif is set. an interrupt, indicated by ?g apif = 1, is triggered if interrupt enable bit apie = 1. the timer is re-started automatically again after it has set apif. the procedure to change apiclk or apir[15:0] is ?st to clear apife, then write to apiclk or apir[15:0], and afterwards set apife. the api trimming bits aclktr[5:0] must be set so the minimum period equals 0.2 ms if stable frequency is desired. see table 10-18 for the trimming effect of aclktr[5:0]. note the ?st period after enabling the counter by apife might be reduced by api start up delay t sdel . it is possible to generate with the api a waveform at the external pin api_extclk by setting apife and enabling the external access with setting apiea. 10.7 initialization/application information 10.7.1 general initialization information usually applications run in mcu normal mode . it is recommended to write the cpmucop register in any case from the application program initialization routine after reset no matter if the cop is used in the application or not, even if a con?uration is loaded via the ?sh memory after reset . by doing a ?ontrolled?write access in mcu normal mode (with the right value for the application) the write once for the cop con?uration bits (wcop,cr[2:0]) takes place which protects these bits from further accidental change . in case of a program sequencing issue (code runaway) the cop con?uration can not be accidentally modi?d anymore . 10.7.2 application information for cop and api usage in many applications the cop is used to check that the program is running and sequencing properly . often the cop is kept running during stop mode and periodic wake-up events are needed to service the cop on time and maybe to check the system status . for such an application it is recommended to use the aclk as clock source for both cop and api . this guarantees lowest possible idd current during stop mode . additionally it eases software implementation using the same clock source for both, cop and api . the interrupt service routine (isr) of the autonomous periodic interrupt api should contain the write instruction to the cpmuarmcop register . the value (byte) written is derived from the ?ain routine (alternating sequence of $55 and $aa) of the application software . using this method, then in the case of a runtime or program sequencing issue the application ?ain routine is not executed properly anymore and the alternating values are not provided properly . hence the
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 freescale semiconductor 417 cop is written at the correct time (due to independent api interrupt request) but the wrong value is written (alternating sequence of $55 and $aa is no longer maintained) which causes a cop reset .
s12 clock, reset and power management unit (s12cpmu) mc9s12g family reference manual, rev.1.23 418 freescale semiconductor
mc9s12g family reference manual, rev.1.23 freescale semiconductor 419 chapter 11 analog-to-digital converter (adc10b8cv2) revision history 11.1 introduction the adc10b8c is a 8-channel, 10-bit, multiplexed input successive approximation analog-to-digital converter. refer to device electrical speci?ations for atd accuracy. version number revision date effective date author description of changes v02.00 13 may 2009 13 may 2009 initial version copied from v01.05, changed unused bits in atddien to read logic 1 v02.01 17 dec 2009 17 dec 2009 updated table 11-15 analog input channel select coding - description of internal channels. updated register atddr (left/right justi?d result) description in section 11.3.2.12.1/11-438 and 11.3.2.12.2/11-439 and added table 11-21 to improve feature description. v02.02 09 feb 2010 09 feb 2010 fixed typo in table 11-9 - conversion result for 3mv and 10bit resolution v02.03 26 feb 2010 26 feb 2010 corrected table 11-15 analog input channel select coding - description of internal channels. v02.04 14 apr 2010 14 apr 2010 corrected typos to be in-line with soc level pin naming conventions for vdda, vssa, vrl and vrh. v02.05 25 aug 2010 25 aug 2010 removed feature of conversion during stop and general wording clean up done in section 11.4, ?unctional description v02.06 09 sep 2010 09 sep 2010 update of internal only information. v02.07 11 feb 2011 11 feb 2011 connectivity information regarding internal channel_6 added to table 11-15 . v02.08 22. jun 2012 22. jun 2012 updated register wirte access information in section 11.3.2.9/11-436 v02.09 29. jun 2012 29 jun 2012 removed ip name in block diagram figure 11-1 v02.10 02 oct 2012 02 oct 2012 added user information to avoid maybe false external trigger events when enabling the external trigger mode ( section 11.4.2.1, ?xternal trigger input ).
analog-to-digital converter (adc10b8cv2) mc9s12g family reference manual, rev.1.23 420 freescale semiconductor 11.1.1 features 8-, 10-bit resolution. automatic return to low power after conversion sequence automatic compare with interrupt for higher than or less/equal than programmable value programmable sample time. left/right justi?d result data. external trigger control. sequence complete interrupt. analog input multiplexer for 8 analog input channels. special conversions for vrh, vrl, (vrl+vrh)/2 and adc temperature sensor. 1-to-8 conversion sequence lengths. continuous conversion mode. multiple channel scans. con?urable external trigger functionality on any ad channel or any of four additional trigger inputs. the four additional trigger inputs can be chip external or internal. refer to device speci?ation for availability and connectivity. con?urable location for channel wrap around (when converting multiple channels in a sequence).
analog-to-digital converter (adc10b8cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 421 11.1.2 modes of operation 11.1.2.1 conversion modes there is software programmable selection between performing single or continuous conversion on a single channel or multiple channels . 11.1.2.2 mcu operating modes stop mode entering stop mode aborts any conversion sequence in progress and if a sequence was aborted restarts it after exiting stop mode. this has the same effect/consequences as starting a conversion sequence with write to atdctl5. so after exiting from stop mode with a previously aborted sequence all ?gs are cleared etc. wait mode adc10b8c behaves same in run and wait mode. for reduced power consumption continuous conversions should be aborted before entering wait mode. freeze mode in freeze mode the adc10b8c will either continue or ?ish or stop converting according to the frz1 and frz0 bits. this is useful for debugging and emulation.
analog-to-digital converter (adc10b8cv2) mc9s12g family reference manual, rev.1.23 422 freescale semiconductor 11.1.3 block diagram figure 11-1. adc10b8c block diagram vssa an6 analog mux mode and successive approximation register (sar) results atd 0 atd 1 atd 2 atd 3 atd 4 atd 5 atd 6 atd 7 and dac sample & hold vdda vrl vrh sequence complete + - comparator clock prescaler bus clock atd clock an5 an4 an3 an1 an0 an7 etrig0 (see device speci? cation for availability etrig1 etrig2 etrig3 and connectivity) timing control atddien atdctl1 trigger mux interrupt compare interrupt an2
analog-to-digital converter (adc10b8cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 423 11.2 signal description this section lists all inputs to the adc10b8c block. 11.2.1 detailed signal descriptions 11.2.1.1 an x ( x = 7, 6, 5, 4, 3, 2, 1, 0) this pin serves as the analog input channel x . it can also be con?ured as digital port or external trigger for the atd conversion. 11.2.1.2 etrig3, etrig2, etrig1, etrig0 these inputs can be con?ured to serve as an external trigger for the atd conversion. refer to device speci?ation for availability and connectivity of these inputs! 11.2.1.3 vrh, vrl vrh is the high reference voltage, vrl is the low reference voltage for atd conversion. 11.2.1.4 vdda, vssa these pins are the power supplies for the analog circuitry of the adc10b8c block. 11.3 memory map and register de?ition this section provides a detailed description of all registers accessible in the adc10b8c. 11.3.1 module memory map figure 11-2 gives an overview on all adc10b8c registers. note register address = base address + address offset, where the base address is de?ed at the mcu level and the address offset is de?ed at the module level. address name bit 7 6 5 4 3 2 1 bit 0 0x0000 atdctl0 r reserved 000 wrap3 wrap2 wrap1 wrap0 w 0x0001 atdctl1 r etrigsel sres1 sres0 smp_dis etrigch3 etrigch2 etrigch1 etrigch0 w 0x0002 atdctl2 r0 affc reserved etrigle etrigp etrige ascie acmpie w = unimplemented or reserved figure 11-2. adc10b8c register summary (sheet 1 of 2)
analog-to-digital converter (adc10b8cv2) mc9s12g family reference manual, rev.1.23 424 freescale semiconductor 0x0003 atdctl3 r djm s8c s4c s2c s1c fifo frz1 frz0 w 0x0004 atdctl4 r smp2 smp1 smp0 prs[4:0] w 0x0005 atdctl5 r0 sc scan mult cd cc cb ca w 0x0006 atdstat0 r scf 0 etorf fifor cc3 cc2 cc1 cc0 w 0x0007 unimple- mented r0 000 0 0 0 0 w 0x0008 atdcmpeh r0 000 0 0 0 0 w 0x0009 atdcmpel r cmpe[7:0] w 0x000a atdstat2h r0 000 0 0 0 0 w 0x000b atdstat2l r ccf[7:0] w 0x000c atddienh r1 111 1 1 1 1 w 0x000d atddienl r ien[7:0] w 0x000e atdcmphth r0 000 0 0 0 0 w 0x000f atdcmphtl r cmpht[7:0] w 0x0010 atddr0 r see section 11.3.2.12.1, ?eft justi?d result data (djm=0) and section 11.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0012 atddr1 r see section 11.3.2.12.1, ?eft justi?d result data (djm=0) and section 11.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0014 atddr2 r see section 11.3.2.12.1, ?eft justi?d result data (djm=0) and section 11.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0016 atddr3 r see section 11.3.2.12.1, ?eft justi?d result data (djm=0) and section 11.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0018 atddr4 r see section 11.3.2.12.1, ?eft justi?d result data (djm=0) and section 11.3.2.12.2, ?ight justi?d result data (djm=1) w 0x001a atddr5 r see section 11.3.2.12.1, ?eft justi?d result data (djm=0) and section 11.3.2.12.2, ?ight justi?d result data (djm=1) w 0x001c atddr6 r see section 11.3.2.12.1, ?eft justi?d result data (djm=0) and section 11.3.2.12.2, ?ight justi?d result data (djm=1) w 0x001e atddr7 r see section 11.3.2.12.1, ?eft justi?d result data (djm=0) and section 11.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0020 - 0x002f unimple- mented r 00000000 w address name bit 7 6 5 4 3 2 1 bit 0 = unimplemented or reserved figure 11-2. adc10b8c register summary (sheet 2 of 2)
analog-to-digital converter (adc10b8cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 425 11.3.2 register descriptions this section describes in address order all the adc10b8c registers and their individual bits. 11.3.2.1 atd control register 0 (atdctl0) writes to this register will abort current conversion sequence. read: anytime write: anytime, in special modes always write 0 to reserved bit 7. module base + 0x0000 76543210 r reserved 000 wrap3 wrap2 wrap1 wrap0 w reset 0 0 0 01111 = unimplemented or reserved figure 11-3. atd control register 0 (atdctl0) table 11-1. atdctl0 field descriptions field description 3-0 wrap[3-0] wrap around channel select bits ?these bits determine the channel for wrap around when doing multi-channel conversions. the coding is summarized in table 11-2 . table 11-2. multi-channel wrap around coding wrap3 wrap2 wrap1 wrap0 multiple channel conversions (mult = 1) wraparound to an0 after converting 0000 reserved 1 0001 an1 0010 an2 0011 an3 0100 an4 0101 an5 0110 an6 0111 an7 1000 an7 1001 an7 1010 an7 1011 an7 1100 an7 1101 an7 1110 an7 1111 an7
analog-to-digital converter (adc10b8cv2) mc9s12g family reference manual, rev.1.23 426 freescale semiconductor 11.3.2.2 atd control register 1 (atdctl1) writes to this register will abort current conversion sequence. read: anytime write: anytime 1 if only an0 should be converted use mult=0. module base + 0x0001 76543210 r etrigsel sres1 sres0 smp_dis etrigch3 etrigch2 etrigch1 etrigch0 w reset 0 0 1 01111 figure 11-4. atd control register 1 (atdctl1) table 11-3. atdctl1 field descriptions field description 7 etrigsel external trigger source select ?this bit selects the external trigger source to be either one of the ad channels or one of the etrig3-0 inputs. see device speci?ation for availability and connectivity of etrig3-0 inputs. if a particular etrig3-0 input option is not available, writing a 1 to etrisel only sets the bit but has no effect, this means that one of the ad channels (selected by etrigch3-0) is con?ured as the source for external trigger. the coding is summarized in table 11-5 . 6? sres[1:0] a/d resolution select ?these bits select the resolution of a/d conversion results. see table 11-4 for coding. 4 smp_dis discharge before sampling bit 0 no discharge before sampling. 1 the internal sample capacitor is discharged before sampling the channel. this adds 2 atd clock cycles to the sampling time. this can help to detect an open circuit instead of measuring the previous sampled channel. 3? etrigch[3:0] external trigger channel select these bits select one of the ad channels or one of the etrig3-0 inputs as source for the external trigger. the coding is summarized in table 11-5 . table 11-4. a/d resolution coding sres1 sres0 a/d resolution 0 0 8-bit data 0 1 10-bit data 1 0 reserved 1 1 reserved
analog-to-digital converter (adc10b8cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 427 11.3.2.3 atd control register 2 (atdctl2) writes to this register will abort current conversion sequence. read: anytime write: anytime table 11-5. external trigger channel select coding etrigsel etrigch3 etrigch2 etrigch1 etrigch0 external trigger source is 0 0 0 0 0 an0 0 0 0 0 1 an1 0 0 0 1 0 an2 0 0 0 1 1 an3 0 0 1 0 0 an4 0 0 1 0 1 an5 0 0 1 1 0 an6 0 0 1 1 1 an7 0 1 0 0 0 an7 0 1 0 0 1 an7 0 1 0 1 0 an7 0 1 0 1 1 an7 0 1 1 0 0 an7 0 1 1 0 1 an7 0 1 1 1 0 an7 0 1 1 1 1 an7 1 0 0 0 0 etrig0 1 1 only if etrig3-0 input option is available (see device speci?ation), else etrisel is ignored, that means external trigger source is still on one of the ad channels selected by etrigch3-0 1 0 0 0 1 etrig1 1 1 0 0 1 0 etrig2 1 1 0 0 1 1 etrig3 1 1 0 1 x x reserved 1 1 x x x reserved module base + 0x0002 76543210 r0 affc reserved etrigle etrigp etrige ascie acmpie w reset 0 0 0 00000 = unimplemented or reserved figure 11-5. atd control register 2 (atdctl2)
analog-to-digital converter (adc10b8cv2) mc9s12g family reference manual, rev.1.23 428 freescale semiconductor table 11-6. atdctl2 field descriptions field description 6 affc atd fast flag clear all 0 atd ?g clearing done by write 1 to respective ccf[ n ] ?g. 1 changes all atd conversion complete ?gs to a fast clear sequence. for compare disabled (cmpe[ n ]=0) a read access to the result register will cause the associated ccf[ n ] ?g to clear automatically. for compare enabled (cmpe[ n ]=1) a write access to the result register will cause the associated ccf[ n ] ?g to clear automatically. 5 reserved do not alter this bit from its reset value.it is for manufacturer use only and can change the atd behavior. 4 etrigle external trigger level/edge control ?this bit controls the sensitivity of the external trigger signal. see table 11-7 for details. 3 etrigp external trigger polarity this bit controls the polarity of the external trigger signal. see table 11-7 for details. 2 etrige external trigger mode enable this bit enables the external trigger on one of the ad channels or one of the etrig3-0 inputs as described in table 11-5 . if the external trigger source is one of the ad channels, the digital input buffer of this channel is enabled. the external trigger allows to synchronize the start of conversion with external events. 0 disable external trigger 1 enable external trigger 1 ascie atd sequence complete interrupt enable 0 atd sequence complete interrupt requests are disabled. 1 atd sequence complete interrupt will be requested whenever scf=1 is set. 0 acmpie atd compare interrupt enable if automatic compare is enabled for conversion n (cmpe[ n ]=1 in atdcmpe register) this bit enables the compare interrupt. if the ccf[ n ] ?g is set (showing a successful compare for conversion n ), the compare interrupt is triggered. 0 atd compare interrupt requests are disabled. 1 for the conversions in a sequence for which automatic compare is enabled (cmpe[ n ]=1), an atd compare interrupt will be requested whenever any of the respective ccf ?gs is set. table 11-7. external trigger con?urations etrigle etrigp external trigger sensitivity 0 0 falling edge 0 1 rising edge 1 0 low level 1 1 high level
analog-to-digital converter (adc10b8cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 429 11.3.2.4 atd control register 3 (atdctl3) writes to this register will abort current conversion sequence. read: anytime write: anytime module base + 0x0003 76543210 r djm s8c s4c s2c s1c fifo frz1 frz0 w reset 0 0 1 00000 = unimplemented or reserved figure 11-6. atd control register 3 (atdctl3) table 11-8. atdctl3 field descriptions field description 7 djm result register data justi?ation ?result data format is always unsigned. this bit controls justi?ation of conversion data in the result registers. 0 left justi?d data in the result registers. 1 right justi?d data in the result registers. table 11-9 gives example atd results for an input signal range between 0 and 5.12 volts. 6? s8c, s4c, s2c, s1c conversion sequence length ?these bits control the number of conversions per sequence. table 11-10 shows all combinations. at reset, s4c is set to 1 (sequence length is 4). this is to maintain software continuity to hc12 family. 2 fifo result register fifo mode if this bit is zero (non-fifo mode), the a/d conversion results map into the result registers based on the conversion sequence; the result of the ?st conversion appears in the ?st result register (atddr0), the second result in the second result register (atddr1), and so on. if this bit is one (fifo mode) the conversion counter is not reset at the beginning or end of a conversion sequence; sequential conversion results are placed in consecutive result registers. in a continuously scanning conversion sequence, the result register counter will wrap around when it reaches the end of the result register ?e. the conversion counter value (cc3-0 in atdstat0) can be used to determine where in the result register ?e, the current conversion result will be placed. aborting a conversion or starting a new conversion clears the conversion counter even if fifo=1. so the ?st result of a new conversion sequence, started by writing to atdctl5, will always be place in the ?st result register (atdddr0). intended usage of fifo mode is continuos conversion (scan=1) or triggered conversion (etrig=1). which result registers hold valid data can be tracked using the conversion complete ?gs. fast ?g clear mode may be useful in a particular application to track valid data. if this bit is one, automatic compare of result registers is always disabled, that is adc10b8c will behave as if acmpie and all cpme[ n ] were zero. 0 conversion results are placed in the corresponding result register up to the selected sequence length. 1 conversion results are placed in consecutive result registers (wrap around at end). 1? frz[1:0] background debug freeze enable ?when debugging an application, it is useful in many cases to have the atd pause when a breakpoint (freeze mode) is encountered. these 2 bits determine how the atd will respond to a breakpoint as shown in table 11-11 . leakage onto the storage node and comparator reference capacitors may compromise the accuracy of an immediately frozen conversion depending on the length of the freeze period.
analog-to-digital converter (adc10b8cv2) mc9s12g family reference manual, rev.1.23 430 freescale semiconductor table 11-9. examples of ideal decimal atd results input signal vrl = 0 volts vrh = 5.12 volts 8-bit codes (resolution=20mv) 10-bit codes (resolution=5mv) reserved 5.120 volts ... 0.022 0.020 0.018 0.016 0.014 0.012 0.010 0.008 0.006 0.004 0.003 0.002 0.000 255 ... 1 1 1 1 1 1 1 0 0 0 0 0 0 1023 ... 4 4 4 3 3 2 2 2 1 1 1 0 0 reserved table 11-10. conversion sequence length coding s8c s4c s2c s1c number of conversions per sequence 00 0 0 8 00 0 1 1 00 1 0 2 00 1 1 3 01 0 0 4 01 0 1 5 01 1 0 6 01 1 1 7 10 0 0 8 10 0 1 8 10 1 0 8 10 1 1 8 11 0 0 8 11 0 1 8 11 1 0 8 11 1 1 8 table 11-11. atd behavior in freeze mode (breakpoint) frz1 frz0 behavior in freeze mode 0 0 continue conversion
analog-to-digital converter (adc10b8cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 431 11.3.2.5 atd control register 4 (atdctl4) writes to this register will abort current conversion sequence. read: anytime write: anytime 0 1 reserved 1 0 finish current conversion, then freeze 1 1 freeze immediately module base + 0x0004 76543210 r smp2 smp1 smp0 prs[4:0] w reset 0 0 0 00101 figure 11-7. atd control register 4 (atdctl4) table 11-12. atdctl4 field descriptions field description 7? smp[2:0] sample time select ?these three bits select the length of the sample time in units of atd conversion clock cycles. note that the atd conversion clock period is itself a function of the prescaler value (bits prs4-0). table 11-13 lists the available sample time lengths. 4? prs[4:0] atd clock prescaler these 5 bits are the binary prescaler value prs. the atd conversion clock frequency is calculated as follows: refer to device speci?ation for allowed frequency range of f atdclk . table 11-13. sample time select smp2 smp1 smp0 sample time in number of atd clock cycles 000 4 001 6 010 8 011 10 100 12 101 16 110 20 111 24 table 11-11. atd behavior in freeze mode (breakpoint) frz1 frz0 behavior in freeze mode f atdclk f bus 2 prs 1 + () ------------------------------------- =
analog-to-digital converter (adc10b8cv2) mc9s12g family reference manual, rev.1.23 432 freescale semiconductor 11.3.2.6 atd control register 5 (atdctl5) writes to this register will abort current conversion sequence and start a new conversion sequence. if the external trigger function is enabled (etrige=1) an initial write to atdctl5 is required to allow starting of a conversion sequence which will then occur on each trigger event. start of conversion means the beginning of the sampling phase. read: anytime write: anytime module base + 0x0005 76543210 r0 sc scan mult cd cc cb ca w reset 0 0 0 00000 = unimplemented or reserved figure 11-8. atd control register 5 (atdctl5) table 11-14. atdctl5 field descriptions field description 6 sc special channel conversion bit if this bit is set, then special channel conversion can be selected using cd, cc, cb and ca of atdctl5. table 11-15 lists the coding. 0 special channel conversions disabled 1 special channel conversions enabled 5 scan continuous conversion sequence mode ?this bit selects whether conversion sequences are performed continuously or only once. if the external trigger function is enabled (etrige=1) setting this bit has no effect, thus the external trigger always starts a single conversion sequence. 0 single conversion sequence 1 continuous conversion sequences (scan mode) 4 mult multi-channel sample mode when mult is 0, the atd sequence controller samples only from the speci?d analog input channel for an entire conversion sequence. the analog channel is selected by channel selection code (control bits cd/cc/cb/ca located in atdctl5). when mult is 1, the atd sequence controller samples across channels. the number of channels sampled is determined by the sequence length value (s8c, s4c, s2c, s1c). the ?st analog channel examined is determined by channel selection code (cd, cc, cb, ca control bits); subsequent channels sampled in the sequence are determined by incrementing the channel selection code or wrapping around to an0 (channel 0). 0 sample only one channel 1 sample across several channels 3? cd, cc, cb, ca analog input channel select code ?these bits select the analog input channel(s). table 11-15 lists the coding used to select the various analog input channels. in the case of single channel conversions (mult=0), this selection code speci?s the channel to be examined. in the case of multiple channel conversions (mult=1), this selection code speci?s the ?st channel to be examined in the conversion sequence. subsequent channels are determined by incrementing the channel selection code or wrapping around to an0 (after converting the channel de?ed by the wrap around channel select bits wrap3-0 in atdctl0). when starting with a channel number higher than the one de?ed by wrap3-0 the ?st wrap around will be an7 to an0.
analog-to-digital converter (adc10b8cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 433 table 11-15. analog input channel select coding sc cd cc cb ca analog input channel 00000 an0 0001 an1 0010 an2 0011 an3 0100 an4 0101 an5 0110 an6 0111 an7 1000 an7 1001 an7 1010 an7 1011 an7 1100 an7 1101 an7 1110 an7 1111 an7 1 0 0 0 0 internal_6, temperature sense of adc hardmacro 0 0 0 1 internal_7 0 0 1 0 internal_0 0 0 1 1 internal_1 0100 vrh 0101 vrl 0 1 1 0 (vrh+vrl) / 2 0 1 1 1 reserved 1 0 0 0 internal_2 1 0 0 1 internal_3 1 0 1 0 internal_4 1 0 1 1 internal_5 1 1 x x reserved
analog-to-digital converter (adc10b8cv2) mc9s12g family reference manual, rev.1.23 434 freescale semiconductor 11.3.2.7 atd status register 0 (atdstat0) this register contains the sequence complete flag, overrun ?gs for external trigger and fifo mode, and the conversion counter. read: anytime write: anytime (no effect on (cc3, cc2, cc1, cc0)) module base + 0x0006 76543210 r scf 0 etorf fifor cc3 cc2 cc1 cc0 w reset 0 0 0 00000 = unimplemented or reserved figure 11-9. atd status register 0 (atdstat0) table 11-16. atdstat0 field descriptions field description 7 scf sequence complete flag ?this ?g is set upon completion of a conversion sequence. if conversion sequences are continuously performed (scan=1), the ?g is set after each one is completed. this ?g is cleared when one of the following occurs: a) write ??to scf b) write to atdctl5 (a new conversion sequence is started) c) if affc=1 and a result register is read 0 conversion sequence not completed 1 conversion sequence has completed 5 etorf external trigger overrun flag ?while in edge sensitive mode (etrigle=0), if additional active edges are detected while a conversion sequence is in process the overrun ?g is set. this ?g is cleared when one of the following occurs: a) write ??to etorf b) write to atdctl0,1,2,3,4, atdcmpe or atdcmpht (a conversion sequence is aborted) c) write to atdctl5 (a new conversion sequence is started) 0 no external trigger overrun error has occurred 1 external trigger overrun error has occurred 4 fifor result register overrun flag this bit indicates that a result register has been written to before its associated conversion complete ?g (ccf) has been cleared. this ?g is most useful when using the fifo mode because the ?g potentially indicates that result registers are out of sync with the input channels. however, it is also practical for non-fifo modes, and indicates that a result register has been overwritten before it has been read (i.e. the old data has been lost). this ?g is cleared when one of the following occurs: a) write ??to fifor b) write to atdctl0,1,2,3,4, atdcmpe or atdcmpht (a conversion sequence is aborted) c) write to atdctl5 (a new conversion sequence is started) 0 no overrun has occurred 1 overrun condition exists (result register has been written while associated ccfx ?g was still set)
analog-to-digital converter (adc10b8cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 435 11.3.2.8 atd compare enable register (atdcmpe) writes to this register will abort current conversion sequence. read: anytime write: anytime 3? cc[3:0] conversion counter these 4 read-only bits are the binary value of the conversion counter. the conversion counter points to the result register that will receive the result of the current conversion. e.g. cc3=0, cc2=1, cc1=1, cc0=0 indicates that the result of the current conversion will be in atd result register 6. if in non-fifo mode (fifo=0) the conversion counter is initialized to zero at the beginning and end of the conversion sequence. if in fifo mode (fifo=1) the register counter is not initialized. the conversion counter wraps around when its maximum value is reached. aborting a conversion or starting a new conversion clears the conversion counter even if fifo=1. module base + 0x0008 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r 0 0 0 0 0 000 cmpe[7:0] w reset 0 0 0 0 0 0 0 0 0 0000000 = unimplemented or reserved figure 11-10. atd compare enable register (atdcmpe) table 11-17. atdcmpe field descriptions field description 7? cmpe[7:0] compare enable for conversion number n ( n = 7, 6, 5, 4, 3, 2, 1, 0) of a sequence ( n conversion number, not channel number!) ?these bits enable automatic compare of conversion results individually for conversions of a sequence. the sense of each comparison is determined by the cmpht[ n ] bit in the atdcmpht register. for each conversion number with cmpe[ n ]=1 do the following: 1) write compare value to atddr n result register 2) write compare operator with cmpht[ n ] in atdcpmht register ccf[ n ] in atdstat2 register will ?g individual success of any comparison. 0 no automatic compare 1 automatic compare of results for conversion n of a sequence is enabled. table 11-16. atdstat0 field descriptions (continued) field description
analog-to-digital converter (adc10b8cv2) mc9s12g family reference manual, rev.1.23 436 freescale semiconductor 11.3.2.9 atd status register 2 (atdstat2) this read-only register contains the conversion complete flags ccf[7:0]. read: anytime write: anytime (for details see table 11-18 below) module base + 0x000a 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r 0 0 0 0 0 0 0 0 ccf[7:0] w reset 0 0 0 0 0 0 0 0 0 0000000 = unimplemented or reserved figure 11-11. atd status register 2 (atdstat2) table 11-18. atdstat2 field descriptions field description 7? ccf[7:0] conversion complete flag n ( n = 7, 6, 5, 4, 3, 2, 1, 0) ( n conversion number, not channel number!) ?a conversion complete ?g is set at the end of each conversion in a sequence. the ?gs are associated with the conversion position in a sequence (and also the result register number). therefore in non-?o mode, ccf[4] is set when the ?th conversion in a sequence is complete and the result is available in result register atddr4; ccf[5] is set when the sixth conversion in a sequence is complete and the result is available in atddr5, and so forth. if automatic compare of conversion results is enabled (cmpe[ n ]=1 in atdcmpe), the conversion complete ?g is only set if comparison with atddr n is true. if acmpie=1 a compare interrupt will be requested. in this case, as the atddr n result register is used to hold the compare value, the result will not be stored there at the end of the conversion but is lost. a ?g ccf[ n ] is cleared when one of the following occurs: a) write to atdctl5 (a new conversion sequence is started) b) if affc=0, write ??to ccf[ n ] c) if affc=1 and cmpe[ n ]=0, read of result register atddr n d) if affc=1 and cmpe[ n ]=1, write to result register atddr n in case of a concurrent set and clear on ccf[ n ]: the clearing by method a) will overwrite the set. the clearing by methods b) or c) or d) will be overwritten by the set. 0 conversion number n not completed or successfully compared 1 if (cmpe[ n ]=0): conversion number n has completed. result is ready in atddr n . if (cmpe[ n ]=1): compare for conversion result number n with compare value in atddr n , using compare operator cmpgt[ n ] is true. (no result available in atddr n )
analog-to-digital converter (adc10b8cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 437 11.3.2.10 atd input enable register (atddien) read: anytime write: anytime 11.3.2.11 atd compare higher than register (atdcmpht) writes to this register will abort current conversion sequence. read: anytime write: anytime module base + 0x000c 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r 1 1 1 1 1 111 ien[7:0] w reset 1 1 1 1 1 1 1 1 0 0000000 = unimplemented or reserved figure 11-12. atd input enable register (atddien) table 11-19. atddien field descriptions field description 7? ien[7:0] atd digital input enable on channel x ( x =7,6,5,4,3,2,1,0) this bit controls the digital input buffer from the analog input pin (an x ) to the digital data register. 0 disable digital input buffer to an x pin 1 enable digital input buffer on an x pin. note: setting this bit will enable the corresponding digital input buffer continuously. if this bit is set while simultaneously using it as an analog port, there is potentially increased power consumption because the digital input buffer maybe in the linear region. module base + 0x000e 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r 0 0 0 0 0 000 cmpht[7:0] w reset 0 0 0 0 0 0 0 0 0 0000000 = unimplemented or reserved figure 11-13. atd compare higher than register (atdcmpht) table 11-20. atdcmpht field descriptions field description 7? cmpht[7:0] compare operation higher than enable for conversion number n ( n = 7, 6, 5, 4, 3, 2, 1, 0) of a sequence ( n conversion number, not channel number!) this bit selects the operator for comparison of conversion results. 0 if result of conversion n is lower or same than compare value in atddr n , this is ?gged in atdstat2 1 if result of conversion n is higher than compare value in atddr n , this is ?gged in atdstat2
analog-to-digital converter (adc10b8cv2) mc9s12g family reference manual, rev.1.23 438 freescale semiconductor 11.3.2.12 atd conversion result registers (atddr n ) the a/d conversion results are stored in 8 result registers. results are always in unsigned data representation. left and right justi?ation is selected using the djm control bit in atdctl3. if automatic compare of conversions results is enabled (cmpe[ n ]=1 in atdcmpe), these registers must be written with the compare values in left or right justi?d format depending on the actual value of the djm bit. in this case, as the atddr n register is used to hold the compare value, the result will not be stored there at the end of the conversion but is lost. attention, n is the conversion number, not the channel number! read: anytime write: anytime note for conversions not using automatic compare, results are stored in the result registers after each conversion. in this case avoid writing to atddrn except for initial values, because an a/d result might be overwritten. 11.3.2.12.1 left justi?d result data (djm=0) table 11-21 shows how depending on the a/d resolution the conversion result is transferred to the atd result registers for left justi?d data. compare is always done using all 12 bits of both the conversion result and the compare value in atddrn. module base + 0x0010 = atddr0, 0x0012 = atddr1, 0x0014 = atddr2, 0x0016 = atddr3 0x0018 = atddr4, 0x001a = atddr5, 0x001c = atddr6, 0x001e = atddr7 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r result-bit[11:0] 0 000 w reset 0 0 0 0 0 0 0 0 0 0000000 = unimplemented or reserved figure 11-14. left justi?d atd conversion result register (atddr n ) table 11-21. conversion result mapping to atddrn a/d resolution djm conversion result mapping to atddr n 8-bit data 0 result-bit[11:4] = conversion result, result-bit[3:0]=0000 10-bit data 0 result-bit[11:2] = conversion result, result-bit[1:0]=00
analog-to-digital converter (adc10b8cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 439 11.3.2.12.2 right justi?d result data (djm=1) table 11-22 shows how depending on the a/d resolution the conversion result is transferred to the atd result registers for right justi?d data. compare is always done using all 12 bits of both the conversion result and the compare value in atddrn. module base + 0x0010 = atddr0, 0x0012 = atddr1, 0x0014 = atddr2, 0x0016 = atddr3 0x0018 = atddr4, 0x001a = atddr5, 0x001c = atddr6, 0x001e = atddr7 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r 0 000 result-bit[11:0] w reset 0 0 0 0 0 0 0 0 0 0000000 = unimplemented or reserved figure 11-15. right justi?d atd conversion result register (atddr n ) table 11-22. conversion result mapping to atddrn a/d resolution djm conversion result mapping to atddr n 8-bit data 1 result-bit[7:0] = result, result-bit[11:8]=0000 10-bit data 1 result-bit[9:0] = result, result-bit[11:10]=00
analog-to-digital converter (adc10b8cv2) mc9s12g family reference manual, rev.1.23 440 freescale semiconductor 11.4 functional description the adc10b8c consists of an analog sub-block and a digital sub-block. 11.4.1 analog sub-block the analog sub-block contains all analog electronics required to perform a single conversion. separate power supplies vdda and vssa allow to isolate noise of other mcu circuitry from the analog sub-block. 11.4.1.1 sample and hold machine the sample and hold machine controls the storage and charge of the sample capacitor to the voltage level of the analog signal at the selected adc input channel. during the sample process the analog input connects directly to the storage node. the input analog signals are unipolar and must be within the potential range of vssa to vdda. during the hold process the analog input is disconnected from the storage node. 11.4.1.2 analog input multiplexer the analog input multiplexer connects one of the 8 external analog input channels to the sample and hold machine. 11.4.1.3 analog-to-digital (a/d) machine the a/d machine performs analog to digital conversions. the resolution is program selectable to be either 8 or 10 bits. the a/d machine uses a successive approximation architecture. it functions by comparing the sampled and stored analog voltage with a series of binary coded discrete voltages. by following a binary search algorithm, the a/d machine identi?s the discrete voltage that is nearest to the sampled and stored voltage. when not converting the a/d machine is automatically powered down. only analog input signals within the potential range of vrl to vrh (a/d reference potentials) will result in a non-railed digital output code. 11.4.2 digital sub-block this subsection describes some of the digital features in more detail. see section 11.3.2, ?egister descriptions for all details. 11.4.2.1 external trigger input the external trigger feature allows the user to synchronize atd conversions to an external event rather than relying only on software to trigger the atd module when a conversion is about to take place. the external trigger signal (out of reset atd channel 7, con?urable in atdctl1) is programmable to be edge
analog-to-digital converter (adc10b8cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 441 or level sensitive with polarity control. table 11-23 gives a brief description of the different combinations of control bits and their effect on the external trigger function in order to avoid maybe false trigger events please enable the external digital input via atddien register ?st and in the following enable the external trigger mode by bit etrige.. in either level or edge sensitive mode, the ?st conversion begins when the trigger is received. once etrige is enabled a conversion must be triggered externally after writing the atdctl5 register. during a conversion in edge sensitive mode, if additional trigger events are detected the overrun error ?g etorf is set. if level sensitive mode is active and the external trigger de-asserts and later asserts again during a conversion sequence, this does not constitute an overrun. therefore, the ?g is not set. if the trigger is left active in level sensitive mode when a sequence is about to complete, another sequence will be triggered immediately. 11.4.2.2 general-purpose digital port operation each atd input pin can be switched between analog or digital input functionality. an analog multiplexer makes each atd input pin selected as analog input available to the a/d converter. the pad of the atd input pin is always connected to the analog input channel of the analog mulitplexer. each pad input signal is buffered to the digital port register. table 11-23. external trigger control bits etrigle etrigp etrige scan description x x 0 0 ignores external trigger. performs one conversion sequence and stops. x x 0 1 ignores external trigger. performs continuous conversion sequences. 0 0 1 x trigger falling edge sensitive. performs one conversion sequence per trigger. 0 1 1 x trigger rising edge sensitive. performs one conversion sequence per trigger. 1 0 1 x trigger low level sensitive. performs continuous conversions while trigger level is active. 1 1 1 x trigger high level sensitive. performs continuous conversions while trigger level is active.
analog-to-digital converter (adc10b8cv2) mc9s12g family reference manual, rev.1.23 442 freescale semiconductor this buffer can be turned on or off with the atddien register for each atd input pin. this is important so that the buffer does not draw excess current when an atd input pin is selected as analog input to the adc10b8c. 11.5 resets at reset the adc10b8c is in a power down state. the reset state of each individual bit is listed within the register description section (see section 11.3.2, ?egister descriptions ) which details the registers and their bit-?ld. 11.6 interrupts the interrupts requested by the adc10b8c are listed in table 11-24 . refer to mcu speci?ation for related vector address and priority. see section 11.3.2, ?egister descriptions for further details. table 11-24. atd interrupt vectors interrupt source ccr mask local enable sequence complete interrupt i bit ascie in atdctl2 compare interrupt i bit acmpie in atdctl2
mc9s12g family reference manual, rev.1.23 freescale semiconductor 443 chapter 12 analog-to-digital converter (adc12b8cv2) revision history 12.1 introduction the adc12b8c is a 8-channel, 12-bit, multiplexed input successive approximation analog-to-digital converter. refer to device electrical speci?ations for atd accuracy. version number revision date effective date author description of changes v02.00 13 may 2009 13 may 2009 initial version copied from v01.05, changed unused bits in atddien to read logic 1 v02.01 17 dec 2009 17 dec 2009 updated table 12-15 analog input channel select coding - description of internal channels. updated register atddr (left/right justi?d result) description in section 12.3.2.12.1/12-463 and 12.3.2.12.2/12-464 and added table 12-21 to improve feature description. v02.02 09 feb 2010 09 feb 2010 fixed typo in table 12-9 - conversion result for 3mv and 10bit resolution v02.03 26 feb 2010 26 feb 2010 corrected table 12-15 analog input channel select coding - description of internal channels. v02.04 14 apr 2010 14 apr 2010 corrected typos to be in-line with soc level pin naming conventions for vdda, vssa, vrl and vrh. v02.05 25 aug 2010 25 aug 2010 removed feature of conversion during stop and general wording clean up done in section 12.4, ?unctional description v02.06 09 sep 2010 09 sep 2010 update of internal only information. v02.07 11 feb 2011 11 feb 2011 connectivity information regarding internal channel_6 added to table 12-15 . v02.08 22. jun 2012 22. jun 2012 updated register wirte access information in section 12.3.2.9/12-461 v02.09 29. jun 2012 29 jun 2012 removed ip name in block diagram figure 12-1 v02.10 02 oct 2012 02 oct 2012 added user information to avoid maybe false external trigger events when enabling the external trigger mode ( section 12.4.2.1, ?xternal trigger input ).
analog-to-digital converter (adc12b8cv2) mc9s12g family reference manual, rev.1.23 444 freescale semiconductor 12.1.1 features 8-, 10-, or 12-bit resolution. automatic return to low power after conversion sequence automatic compare with interrupt for higher than or less/equal than programmable value programmable sample time. left/right justi?d result data. external trigger control. sequence complete interrupt. analog input multiplexer for 8 analog input channels. special conversions for vrh, vrl, (vrl+vrh)/2 and adc temperature sensor. 1-to-8 conversion sequence lengths. continuous conversion mode. multiple channel scans. con?urable external trigger functionality on any ad channel or any of four additional trigger inputs. the four additional trigger inputs can be chip external or internal. refer to device speci?ation for availability and connectivity. con?urable location for channel wrap around (when converting multiple channels in a sequence).
analog-to-digital converter (adc12b8cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 445 12.1.2 modes of operation 12.1.2.1 conversion modes there is software programmable selection between performing single or continuous conversion on a single channel or multiple channels . 12.1.2.2 mcu operating modes stop mode entering stop mode aborts any conversion sequence in progress and if a sequence was aborted restarts it after exiting stop mode. this has the same effect/consequences as starting a conversion sequence with write to atdctl5. so after exiting from stop mode with a previously aborted sequence all ?gs are cleared etc. wait mode adc12b8c behaves same in run and wait mode. for reduced power consumption continuous conversions should be aborted before entering wait mode. freeze mode in freeze mode the adc12b8c will either continue or ?ish or stop converting according to the frz1 and frz0 bits. this is useful for debugging and emulation.
analog-to-digital converter (adc12b8cv2) mc9s12g family reference manual, rev.1.23 446 freescale semiconductor 12.1.3 block diagram figure 12-1. adc12b8c block diagram vssa an6 analog mux mode and successive approximation register (sar) results atd 0 atd 1 atd 2 atd 3 atd 4 atd 5 atd 6 atd 7 and dac sample & hold vdda vrl vrh sequence complete + - comparator clock prescaler bus clock atd clock an5 an4 an3 an1 an0 an7 etrig0 (see device speci? cation for availability etrig1 etrig2 etrig3 and connectivity) timing control atddien atdctl1 trigger mux interrupt compare interrupt an2
analog-to-digital converter (adc12b8cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 447 12.2 signal description this section lists all inputs to the adc12b8c block. 12.2.1 detailed signal descriptions 12.2.1.1 an x ( x = 7, 6, 5, 4, 3, 2, 1, 0) this pin serves as the analog input channel x . it can also be con?ured as digital port or external trigger for the atd conversion. 12.2.1.2 etrig3, etrig2, etrig1, etrig0 these inputs can be con?ured to serve as an external trigger for the atd conversion. refer to device speci?ation for availability and connectivity of these inputs! 12.2.1.3 vrh, vrl vrh is the high reference voltage, vrl is the low reference voltage for atd conversion. 12.2.1.4 vdda, vssa these pins are the power supplies for the analog circuitry of the adc12b8c block. 12.3 memory map and register de?ition this section provides a detailed description of all registers accessible in the adc12b8c. 12.3.1 module memory map figure 12-2 gives an overview on all adc12b8c registers. note register address = base address + address offset, where the base address is de?ed at the mcu level and the address offset is de?ed at the module level. address name bit 7 6 5 4 3 2 1 bit 0 0x0000 atdctl0 r reserved 000 wrap3 wrap2 wrap1 wrap0 w 0x0001 atdctl1 r etrigsel sres1 sres0 smp_dis etrigch3 etrigch2 etrigch1 etrigch0 w 0x0002 atdctl2 r0 affc reserved etrigle etrigp etrige ascie acmpie w = unimplemented or reserved figure 12-2. adc12b8c register summary (sheet 1 of 2)
analog-to-digital converter (adc12b8cv2) mc9s12g family reference manual, rev.1.23 448 freescale semiconductor 0x0003 atdctl3 r djm s8c s4c s2c s1c fifo frz1 frz0 w 0x0004 atdctl4 r smp2 smp1 smp0 prs[4:0] w 0x0005 atdctl5 r0 sc scan mult cd cc cb ca w 0x0006 atdstat0 r scf 0 etorf fifor cc3 cc2 cc1 cc0 w 0x0007 unimple- mented r0 000 0 0 0 0 w 0x0008 atdcmpeh r0 000 0 0 0 0 w 0x0009 atdcmpel r cmpe[7:0] w 0x000a atdstat2h r0 000 0 0 0 0 w 0x000b atdstat2l r ccf[7:0] w 0x000c atddienh r1 111 1 1 1 1 w 0x000d atddienl r ien[7:0] w 0x000e atdcmphth r0 000 0 0 0 0 w 0x000f atdcmphtl r cmpht[7:0] w 0x0010 atddr0 r see section 12.3.2.12.1, ?eft justi?d result data (djm=0) and section 12.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0012 atddr1 r see section 12.3.2.12.1, ?eft justi?d result data (djm=0) and section 12.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0014 atddr2 r see section 12.3.2.12.1, ?eft justi?d result data (djm=0) and section 12.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0016 atddr3 r see section 12.3.2.12.1, ?eft justi?d result data (djm=0) and section 12.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0018 atddr4 r see section 12.3.2.12.1, ?eft justi?d result data (djm=0) and section 12.3.2.12.2, ?ight justi?d result data (djm=1) w 0x001a atddr5 r see section 12.3.2.12.1, ?eft justi?d result data (djm=0) and section 12.3.2.12.2, ?ight justi?d result data (djm=1) w 0x001c atddr6 r see section 12.3.2.12.1, ?eft justi?d result data (djm=0) and section 12.3.2.12.2, ?ight justi?d result data (djm=1) w 0x001e atddr7 r see section 12.3.2.12.1, ?eft justi?d result data (djm=0) and section 12.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0020 - 0x002f unimple- mented r 00000000 w address name bit 7 6 5 4 3 2 1 bit 0 = unimplemented or reserved figure 12-2. adc12b8c register summary (sheet 2 of 2)
analog-to-digital converter (adc12b8cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 449 12.3.2 register descriptions this section describes in address order all the adc12b8c registers and their individual bits. 12.3.2.1 atd control register 0 (atdctl0) writes to this register will abort current conversion sequence. read: anytime write: anytime, in special modes always write 0 to reserved bit 7. module base + 0x0000 76543210 r reserved 000 wrap3 wrap2 wrap1 wrap0 w reset 0 0 0 01111 = unimplemented or reserved figure 12-3. atd control register 0 (atdctl0) table 12-1. atdctl0 field descriptions field description 3-0 wrap[3-0] wrap around channel select bits ?these bits determine the channel for wrap around when doing multi-channel conversions. the coding is summarized in table 12-2 . table 12-2. multi-channel wrap around coding wrap3 wrap2 wrap1 wrap0 multiple channel conversions (mult = 1) wraparound to an0 after converting 0000 reserved 1 0001 an1 0010 an2 0011 an3 0100 an4 0101 an5 0110 an6 0111 an7 1000 an7 1001 an7 1010 an7 1011 an7 1100 an7 1101 an7 1110 an7 1111 an7
analog-to-digital converter (adc12b8cv2) mc9s12g family reference manual, rev.1.23 450 freescale semiconductor 12.3.2.2 atd control register 1 (atdctl1) writes to this register will abort current conversion sequence. read: anytime write: anytime 1 if only an0 should be converted use mult=0. module base + 0x0001 76543210 r etrigsel sres1 sres0 smp_dis etrigch3 etrigch2 etrigch1 etrigch0 w reset 0 0 1 01111 figure 12-4. atd control register 1 (atdctl1) table 12-3. atdctl1 field descriptions field description 7 etrigsel external trigger source select ?this bit selects the external trigger source to be either one of the ad channels or one of the etrig3-0 inputs. see device speci?ation for availability and connectivity of etrig3-0 inputs. if a particular etrig3-0 input option is not available, writing a 1 to etrisel only sets the bit but has no effect, this means that one of the ad channels (selected by etrigch3-0) is con?ured as the source for external trigger. the coding is summarized in table 12-5 . 6? sres[1:0] a/d resolution select ?these bits select the resolution of a/d conversion results. see table 12-4 for coding. 4 smp_dis discharge before sampling bit 0 no discharge before sampling. 1 the internal sample capacitor is discharged before sampling the channel. this adds 2 atd clock cycles to the sampling time. this can help to detect an open circuit instead of measuring the previous sampled channel. 3? etrigch[3:0] external trigger channel select these bits select one of the ad channels or one of the etrig3-0 inputs as source for the external trigger. the coding is summarized in table 12-5 . table 12-4. a/d resolution coding sres1 sres0 a/d resolution 0 0 8-bit data 0 1 10-bit data 1 0 12-bit data 1 1 reserved
analog-to-digital converter (adc12b8cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 451 12.3.2.3 atd control register 2 (atdctl2) writes to this register will abort current conversion sequence. read: anytime write: anytime table 12-5. external trigger channel select coding etrigsel etrigch3 etrigch2 etrigch1 etrigch0 external trigger source is 0 0 0 0 0 an0 0 0 0 0 1 an1 0 0 0 1 0 an2 0 0 0 1 1 an3 0 0 1 0 0 an4 0 0 1 0 1 an5 0 0 1 1 0 an6 0 0 1 1 1 an7 0 1 0 0 0 an7 0 1 0 0 1 an7 0 1 0 1 0 an7 0 1 0 1 1 an7 0 1 1 0 0 an7 0 1 1 0 1 an7 0 1 1 1 0 an7 0 1 1 1 1 an7 1 0 0 0 0 etrig0 1 1 only if etrig3-0 input option is available (see device speci?ation), else etrisel is ignored, that means external trigger source is still on one of the ad channels selected by etrigch3-0 1 0 0 0 1 etrig1 1 1 0 0 1 0 etrig2 1 1 0 0 1 1 etrig3 1 1 0 1 x x reserved 1 1 x x x reserved module base + 0x0002 76543210 r0 affc reserved etrigle etrigp etrige ascie acmpie w reset 0 0 0 00000 = unimplemented or reserved figure 12-5. atd control register 2 (atdctl2)
analog-to-digital converter (adc12b8cv2) mc9s12g family reference manual, rev.1.23 452 freescale semiconductor table 12-6. atdctl2 field descriptions field description 6 affc atd fast flag clear all 0 atd ?g clearing done by write 1 to respective ccf[ n ] ?g. 1 changes all atd conversion complete ?gs to a fast clear sequence. for compare disabled (cmpe[ n ]=0) a read access to the result register will cause the associated ccf[ n ] ?g to clear automatically. for compare enabled (cmpe[ n ]=1) a write access to the result register will cause the associated ccf[ n ] ?g to clear automatically. 5 reserved do not alter this bit from its reset value.it is for manufacturer use only and can change the atd behavior. 4 etrigle external trigger level/edge control ?this bit controls the sensitivity of the external trigger signal. see table 12-7 for details. 3 etrigp external trigger polarity this bit controls the polarity of the external trigger signal. see table 12-7 for details. 2 etrige external trigger mode enable this bit enables the external trigger on one of the ad channels or one of the etrig3-0 inputs as described in table 12-5 . if the external trigger source is one of the ad channels, the digital input buffer of this channel is enabled. the external trigger allows to synchronize the start of conversion with external events. 0 disable external trigger 1 enable external trigger 1 ascie atd sequence complete interrupt enable 0 atd sequence complete interrupt requests are disabled. 1 atd sequence complete interrupt will be requested whenever scf=1 is set. 0 acmpie atd compare interrupt enable if automatic compare is enabled for conversion n (cmpe[ n ]=1 in atdcmpe register) this bit enables the compare interrupt. if the ccf[ n ] ?g is set (showing a successful compare for conversion n ), the compare interrupt is triggered. 0 atd compare interrupt requests are disabled. 1 for the conversions in a sequence for which automatic compare is enabled (cmpe[ n ]=1), an atd compare interrupt will be requested whenever any of the respective ccf ?gs is set. table 12-7. external trigger con?urations etrigle etrigp external trigger sensitivity 0 0 falling edge 0 1 rising edge 1 0 low level 1 1 high level
analog-to-digital converter (adc12b8cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 453 12.3.2.4 atd control register 3 (atdctl3) writes to this register will abort current conversion sequence. read: anytime write: anytime module base + 0x0003 76543210 r djm s8c s4c s2c s1c fifo frz1 frz0 w reset 0 0 1 00000 = unimplemented or reserved figure 12-6. atd control register 3 (atdctl3) table 12-8. atdctl3 field descriptions field description 7 djm result register data justi?ation ?result data format is always unsigned. this bit controls justi?ation of conversion data in the result registers. 0 left justi?d data in the result registers. 1 right justi?d data in the result registers. table 12-9 gives example atd results for an input signal range between 0 and 5.12 volts. 6? s8c, s4c, s2c, s1c conversion sequence length ?these bits control the number of conversions per sequence. table 12-10 shows all combinations. at reset, s4c is set to 1 (sequence length is 4). this is to maintain software continuity to hc12 family. 2 fifo result register fifo mode if this bit is zero (non-fifo mode), the a/d conversion results map into the result registers based on the conversion sequence; the result of the ?st conversion appears in the ?st result register (atddr0), the second result in the second result register (atddr1), and so on. if this bit is one (fifo mode) the conversion counter is not reset at the beginning or end of a conversion sequence; sequential conversion results are placed in consecutive result registers. in a continuously scanning conversion sequence, the result register counter will wrap around when it reaches the end of the result register ?e. the conversion counter value (cc3-0 in atdstat0) can be used to determine where in the result register ?e, the current conversion result will be placed. aborting a conversion or starting a new conversion clears the conversion counter even if fifo=1. so the ?st result of a new conversion sequence, started by writing to atdctl5, will always be place in the ?st result register (atdddr0). intended usage of fifo mode is continuos conversion (scan=1) or triggered conversion (etrig=1). which result registers hold valid data can be tracked using the conversion complete ?gs. fast ?g clear mode may be useful in a particular application to track valid data. if this bit is one, automatic compare of result registers is always disabled, that is adc12b8c will behave as if acmpie and all cpme[ n ] were zero. 0 conversion results are placed in the corresponding result register up to the selected sequence length. 1 conversion results are placed in consecutive result registers (wrap around at end). 1? frz[1:0] background debug freeze enable ?when debugging an application, it is useful in many cases to have the atd pause when a breakpoint (freeze mode) is encountered. these 2 bits determine how the atd will respond to a breakpoint as shown in table 12-11 . leakage onto the storage node and comparator reference capacitors may compromise the accuracy of an immediately frozen conversion depending on the length of the freeze period.
analog-to-digital converter (adc12b8cv2) mc9s12g family reference manual, rev.1.23 454 freescale semiconductor table 12-9. examples of ideal decimal atd results input signal vrl = 0 volts vrh = 5.12 volts 8-bit codes (resolution=20mv) 10-bit codes (resolution=5mv) 12-bit codes (transfer curve has 1.25mv offset) (resolution=1.25mv) 5.120 volts ... 0.022 0.020 0.018 0.016 0.014 0.012 0.010 0.008 0.006 0.004 0.003 0.002 0.000 255 ... 1 1 1 1 1 1 1 0 0 0 0 0 0 1023 ... 4 4 4 3 3 2 2 2 1 1 1 0 0 4095 ... 17 16 14 12 11 9 8 6 4 3 2 1 0 table 12-10. conversion sequence length coding s8c s4c s2c s1c number of conversions per sequence 00 0 0 8 00 0 1 1 00 1 0 2 00 1 1 3 01 0 0 4 01 0 1 5 01 1 0 6 01 1 1 7 10 0 0 8 10 0 1 8 10 1 0 8 10 1 1 8 11 0 0 8 11 0 1 8 11 1 0 8 11 1 1 8
analog-to-digital converter (adc12b8cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 455 12.3.2.5 atd control register 4 (atdctl4) writes to this register will abort current conversion sequence. read: anytime write: anytime table 12-11. atd behavior in freeze mode (breakpoint) frz1 frz0 behavior in freeze mode 0 0 continue conversion 0 1 reserved 1 0 finish current conversion, then freeze 1 1 freeze immediately module base + 0x0004 76543210 r smp2 smp1 smp0 prs[4:0] w reset 0 0 0 00101 figure 12-7. atd control register 4 (atdctl4) table 12-12. atdctl4 field descriptions field description 7? smp[2:0] sample time select ?these three bits select the length of the sample time in units of atd conversion clock cycles. note that the atd conversion clock period is itself a function of the prescaler value (bits prs4-0). table 12-13 lists the available sample time lengths. 4? prs[4:0] atd clock prescaler these 5 bits are the binary prescaler value prs. the atd conversion clock frequency is calculated as follows: refer to device speci?ation for allowed frequency range of f atdclk . table 12-13. sample time select smp2 smp1 smp0 sample time in number of atd clock cycles 000 4 001 6 010 8 011 10 100 12 101 16 110 20 f atdclk f bus 2 prs 1 + () ------------------------------------- =
analog-to-digital converter (adc12b8cv2) mc9s12g family reference manual, rev.1.23 456 freescale semiconductor 12.3.2.6 atd control register 5 (atdctl5) writes to this register will abort current conversion sequence and start a new conversion sequence. if the external trigger function is enabled (etrige=1) an initial write to atdctl5 is required to allow starting of a conversion sequence which will then occur on each trigger event. start of conversion means the beginning of the sampling phase. read: anytime write: anytime 111 24 module base + 0x0005 76543210 r0 sc scan mult cd cc cb ca w reset 0 0 0 00000 = unimplemented or reserved figure 12-8. atd control register 5 (atdctl5) table 12-14. atdctl5 field descriptions field description 6 sc special channel conversion bit if this bit is set, then special channel conversion can be selected using cd, cc, cb and ca of atdctl5. table 12-15 lists the coding. 0 special channel conversions disabled 1 special channel conversions enabled 5 scan continuous conversion sequence mode ?this bit selects whether conversion sequences are performed continuously or only once. if the external trigger function is enabled (etrige=1) setting this bit has no effect, thus the external trigger always starts a single conversion sequence. 0 single conversion sequence 1 continuous conversion sequences (scan mode) table 12-13. sample time select smp2 smp1 smp0 sample time in number of atd clock cycles
analog-to-digital converter (adc12b8cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 457 4 mult multi-channel sample mode when mult is 0, the atd sequence controller samples only from the speci?d analog input channel for an entire conversion sequence. the analog channel is selected by channel selection code (control bits cd/cc/cb/ca located in atdctl5). when mult is 1, the atd sequence controller samples across channels. the number of channels sampled is determined by the sequence length value (s8c, s4c, s2c, s1c). the ?st analog channel examined is determined by channel selection code (cd, cc, cb, ca control bits); subsequent channels sampled in the sequence are determined by incrementing the channel selection code or wrapping around to an0 (channel 0). 0 sample only one channel 1 sample across several channels 3? cd, cc, cb, ca analog input channel select code ?these bits select the analog input channel(s). table 12-15 lists the coding used to select the various analog input channels. in the case of single channel conversions (mult=0), this selection code speci?s the channel to be examined. in the case of multiple channel conversions (mult=1), this selection code speci?s the ?st channel to be examined in the conversion sequence. subsequent channels are determined by incrementing the channel selection code or wrapping around to an0 (after converting the channel de?ed by the wrap around channel select bits wrap3-0 in atdctl0). when starting with a channel number higher than the one de?ed by wrap3-0 the ?st wrap around will be an7 to an0. table 12-15. analog input channel select coding sc cd cc cb ca analog input channel 00000 an0 0001 an1 0010 an2 0011 an3 0100 an4 0101 an5 0110 an6 0111 an7 1000 an7 1001 an7 1010 an7 1011 an7 1100 an7 1101 an7 1110 an7 1111 an7 table 12-14. atdctl5 field descriptions (continued) field description
analog-to-digital converter (adc12b8cv2) mc9s12g family reference manual, rev.1.23 458 freescale semiconductor 1 0 0 0 0 internal_6, temperature sense of adc hardmacro 0 0 0 1 internal_7 0 0 1 0 internal_0 0 0 1 1 internal_1 0100 vrh 0101 vrl 0 1 1 0 (vrh+vrl) / 2 0 1 1 1 reserved 1 0 0 0 internal_2 1 0 0 1 internal_3 1 0 1 0 internal_4 1 0 1 1 internal_5 1 1 x x reserved table 12-15. analog input channel select coding sc cd cc cb ca analog input channel
analog-to-digital converter (adc12b8cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 459 12.3.2.7 atd status register 0 (atdstat0) this register contains the sequence complete flag, overrun ?gs for external trigger and fifo mode, and the conversion counter. read: anytime write: anytime (no effect on (cc3, cc2, cc1, cc0)) module base + 0x0006 76543210 r scf 0 etorf fifor cc3 cc2 cc1 cc0 w reset 0 0 0 00000 = unimplemented or reserved figure 12-9. atd status register 0 (atdstat0) table 12-16. atdstat0 field descriptions field description 7 scf sequence complete flag ?this ?g is set upon completion of a conversion sequence. if conversion sequences are continuously performed (scan=1), the ?g is set after each one is completed. this ?g is cleared when one of the following occurs: a) write ??to scf b) write to atdctl5 (a new conversion sequence is started) c) if affc=1 and a result register is read 0 conversion sequence not completed 1 conversion sequence has completed 5 etorf external trigger overrun flag ?while in edge sensitive mode (etrigle=0), if additional active edges are detected while a conversion sequence is in process the overrun ?g is set. this ?g is cleared when one of the following occurs: a) write ??to etorf b) write to atdctl0,1,2,3,4, atdcmpe or atdcmpht (a conversion sequence is aborted) c) write to atdctl5 (a new conversion sequence is started) 0 no external trigger overrun error has occurred 1 external trigger overrun error has occurred 4 fifor result register overrun flag this bit indicates that a result register has been written to before its associated conversion complete ?g (ccf) has been cleared. this ?g is most useful when using the fifo mode because the ?g potentially indicates that result registers are out of sync with the input channels. however, it is also practical for non-fifo modes, and indicates that a result register has been overwritten before it has been read (i.e. the old data has been lost). this ?g is cleared when one of the following occurs: a) write ??to fifor b) write to atdctl0,1,2,3,4, atdcmpe or atdcmpht (a conversion sequence is aborted) c) write to atdctl5 (a new conversion sequence is started) 0 no overrun has occurred 1 overrun condition exists (result register has been written while associated ccfx ?g was still set)
analog-to-digital converter (adc12b8cv2) mc9s12g family reference manual, rev.1.23 460 freescale semiconductor 12.3.2.8 atd compare enable register (atdcmpe) writes to this register will abort current conversion sequence. read: anytime write: anytime 3? cc[3:0] conversion counter these 4 read-only bits are the binary value of the conversion counter. the conversion counter points to the result register that will receive the result of the current conversion. e.g. cc3=0, cc2=1, cc1=1, cc0=0 indicates that the result of the current conversion will be in atd result register 6. if in non-fifo mode (fifo=0) the conversion counter is initialized to zero at the beginning and end of the conversion sequence. if in fifo mode (fifo=1) the register counter is not initialized. the conversion counter wraps around when its maximum value is reached. aborting a conversion or starting a new conversion clears the conversion counter even if fifo=1. module base + 0x0008 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r 0 0 0 0 0 000 cmpe[7:0] w reset 0 0 0 0 0 0 0 0 0 0000000 = unimplemented or reserved figure 12-10. atd compare enable register (atdcmpe) table 12-17. atdcmpe field descriptions field description 7? cmpe[7:0] compare enable for conversion number n ( n = 7, 6, 5, 4, 3, 2, 1, 0) of a sequence ( n conversion number, not channel number!) ?these bits enable automatic compare of conversion results individually for conversions of a sequence. the sense of each comparison is determined by the cmpht[ n ] bit in the atdcmpht register. for each conversion number with cmpe[ n ]=1 do the following: 1) write compare value to atddr n result register 2) write compare operator with cmpht[ n ] in atdcpmht register ccf[ n ] in atdstat2 register will ?g individual success of any comparison. 0 no automatic compare 1 automatic compare of results for conversion n of a sequence is enabled. table 12-16. atdstat0 field descriptions (continued) field description
analog-to-digital converter (adc12b8cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 461 12.3.2.9 atd status register 2 (atdstat2) this read-only register contains the conversion complete flags ccf[7:0]. read: anytime write: anytime (for details see table 12-18 below) module base + 0x000a 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r 0 0 0 0 0 0 0 0 ccf[7:0] w reset 0 0 0 0 0 0 0 0 0 0000000 = unimplemented or reserved figure 12-11. atd status register 2 (atdstat2) table 12-18. atdstat2 field descriptions field description 7? ccf[7:0] conversion complete flag n ( n = 7, 6, 5, 4, 3, 2, 1, 0) ( n conversion number, not channel number!) ?a conversion complete ?g is set at the end of each conversion in a sequence. the ?gs are associated with the conversion position in a sequence (and also the result register number). therefore in non-?o mode, ccf[4] is set when the ?th conversion in a sequence is complete and the result is available in result register atddr4; ccf[5] is set when the sixth conversion in a sequence is complete and the result is available in atddr5, and so forth. if automatic compare of conversion results is enabled (cmpe[ n ]=1 in atdcmpe), the conversion complete ?g is only set if comparison with atddr n is true. if acmpie=1 a compare interrupt will be requested. in this case, as the atddr n result register is used to hold the compare value, the result will not be stored there at the end of the conversion but is lost. a ?g ccf[ n ] is cleared when one of the following occurs: a) write to atdctl5 (a new conversion sequence is started) b) if affc=0, write ??to ccf[ n ] c) if affc=1 and cmpe[ n ]=0, read of result register atddr n d) if affc=1 and cmpe[ n ]=1, write to result register atddr n in case of a concurrent set and clear on ccf[ n ]: the clearing by method a) will overwrite the set. the clearing by methods b) or c) or d) will be overwritten by the set. 0 conversion number n not completed or successfully compared 1 if (cmpe[ n ]=0): conversion number n has completed. result is ready in atddr n . if (cmpe[ n ]=1): compare for conversion result number n with compare value in atddr n , using compare operator cmpgt[ n ] is true. (no result available in atddr n )
analog-to-digital converter (adc12b8cv2) mc9s12g family reference manual, rev.1.23 462 freescale semiconductor 12.3.2.10 atd input enable register (atddien) read: anytime write: anytime 12.3.2.11 atd compare higher than register (atdcmpht) writes to this register will abort current conversion sequence. read: anytime write: anytime module base + 0x000c 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r 1 1 1 1 1 111 ien[7:0] w reset 1 1 1 1 1 1 1 1 0 0000000 = unimplemented or reserved figure 12-12. atd input enable register (atddien) table 12-19. atddien field descriptions field description 7? ien[7:0] atd digital input enable on channel x ( x =7,6,5,4,3,2,1,0) this bit controls the digital input buffer from the analog input pin (an x ) to the digital data register. 0 disable digital input buffer to an x pin 1 enable digital input buffer on an x pin. note: setting this bit will enable the corresponding digital input buffer continuously. if this bit is set while simultaneously using it as an analog port, there is potentially increased power consumption because the digital input buffer maybe in the linear region. module base + 0x000e 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r 0 0 0 0 0 000 cmpht[7:0] w reset 0 0 0 0 0 0 0 0 0 0000000 = unimplemented or reserved figure 12-13. atd compare higher than register (atdcmpht) table 12-20. atdcmpht field descriptions field description 7? cmpht[7:0] compare operation higher than enable for conversion number n ( n = 7, 6, 5, 4, 3, 2, 1, 0) of a sequence ( n conversion number, not channel number!) this bit selects the operator for comparison of conversion results. 0 if result of conversion n is lower or same than compare value in atddr n , this is ?gged in atdstat2 1 if result of conversion n is higher than compare value in atddr n , this is ?gged in atdstat2
analog-to-digital converter (adc12b8cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 463 12.3.2.12 atd conversion result registers (atddr n ) the a/d conversion results are stored in 8 result registers. results are always in unsigned data representation. left and right justi?ation is selected using the djm control bit in atdctl3. if automatic compare of conversions results is enabled (cmpe[ n ]=1 in atdcmpe), these registers must be written with the compare values in left or right justi?d format depending on the actual value of the djm bit. in this case, as the atddr n register is used to hold the compare value, the result will not be stored there at the end of the conversion but is lost. attention, n is the conversion number, not the channel number! read: anytime write: anytime note for conversions not using automatic compare, results are stored in the result registers after each conversion. in this case avoid writing to atddrn except for initial values, because an a/d result might be overwritten. 12.3.2.12.1 left justi?d result data (djm=0) table 12-21 shows how depending on the a/d resolution the conversion result is transferred to the atd result registers for left justi?d data. compare is always done using all 12 bits of both the conversion result and the compare value in atddrn. module base + 0x0010 = atddr0, 0x0012 = atddr1, 0x0014 = atddr2, 0x0016 = atddr3 0x0018 = atddr4, 0x001a = atddr5, 0x001c = atddr6, 0x001e = atddr7 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r result-bit[11:0] 0 000 w reset 0 0 0 0 0 0 0 0 0 0000000 = unimplemented or reserved figure 12-14. left justi?d atd conversion result register (atddr n ) table 12-21. conversion result mapping to atddrn a/d resolution djm conversion result mapping to atddr n 8-bit data 0 result-bit[11:4] = conversion result, result-bit[3:0]=0000 10-bit data 0 result-bit[11:2] = conversion result, result-bit[1:0]=00 12-bit data 0 result-bit[11:0] = result
analog-to-digital converter (adc12b8cv2) mc9s12g family reference manual, rev.1.23 464 freescale semiconductor 12.3.2.12.2 right justi?d result data (djm=1) table 12-22 shows how depending on the a/d resolution the conversion result is transferred to the atd result registers for right justi?d data. compare is always done using all 12 bits of both the conversion result and the compare value in atddrn. module base + 0x0010 = atddr0, 0x0012 = atddr1, 0x0014 = atddr2, 0x0016 = atddr3 0x0018 = atddr4, 0x001a = atddr5, 0x001c = atddr6, 0x001e = atddr7 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r 0 000 result-bit[11:0] w reset 0 0 0 0 0 0 0 0 0 0000000 = unimplemented or reserved figure 12-15. right justi?d atd conversion result register (atddr n ) table 12-22. conversion result mapping to atddrn a/d resolution djm conversion result mapping to atddr n 8-bit data 1 result-bit[7:0] = result, result-bit[11:8]=0000 10-bit data 1 result-bit[9:0] = result, result-bit[11:10]=00 12-bit data 1 result-bit[11:0] = result
analog-to-digital converter (adc12b8cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 465 12.4 functional description the adc12b8c consists of an analog sub-block and a digital sub-block. 12.4.1 analog sub-block the analog sub-block contains all analog electronics required to perform a single conversion. separate power supplies vdda and vssa allow to isolate noise of other mcu circuitry from the analog sub-block. 12.4.1.1 sample and hold machine the sample and hold machine controls the storage and charge of the sample capacitor to the voltage level of the analog signal at the selected adc input channel. during the sample process the analog input connects directly to the storage node. the input analog signals are unipolar and must be within the potential range of vssa to vdda. during the hold process the analog input is disconnected from the storage node. 12.4.1.2 analog input multiplexer the analog input multiplexer connects one of the 8 external analog input channels to the sample and hold machine. 12.4.1.3 analog-to-digital (a/d) machine the a/d machine performs analog to digital conversions. the resolution is program selectable to be either 8 or 10 or 12 bits. the a/d machine uses a successive approximation architecture. it functions by comparing the sampled and stored analog voltage with a series of binary coded discrete voltages. by following a binary search algorithm, the a/d machine identi?s the discrete voltage that is nearest to the sampled and stored voltage. when not converting the a/d machine is automatically powered down. only analog input signals within the potential range of vrl to vrh (a/d reference potentials) will result in a non-railed digital output code. 12.4.2 digital sub-block this subsection describes some of the digital features in more detail. see section 12.3.2, ?egister descriptions for all details. 12.4.2.1 external trigger input the external trigger feature allows the user to synchronize atd conversions to an external event rather than relying only on software to trigger the atd module when a conversion is about to take place. the external trigger signal (out of reset atd channel 7, con?urable in atdctl1) is programmable to be edge
analog-to-digital converter (adc12b8cv2) mc9s12g family reference manual, rev.1.23 466 freescale semiconductor or level sensitive with polarity control. table 12-23 gives a brief description of the different combinations of control bits and their effect on the external trigger function in order to avoid maybe false trigger events please enable the external digital input via atddien register ?st and in the following enable the external trigger mode by bit etrige.. in either level or edge sensitive mode, the ?st conversion begins when the trigger is received. once etrige is enabled a conversion must be triggered externally after writing the atdctl5 register. during a conversion in edge sensitive mode, if additional trigger events are detected the overrun error ?g etorf is set. if level sensitive mode is active and the external trigger de-asserts and later asserts again during a conversion sequence, this does not constitute an overrun. therefore, the ?g is not set. if the trigger is left active in level sensitive mode when a sequence is about to complete, another sequence will be triggered immediately. 12.4.2.2 general-purpose digital port operation each atd input pin can be switched between analog or digital input functionality. an analog multiplexer makes each atd input pin selected as analog input available to the a/d converter. the pad of the atd input pin is always connected to the analog input channel of the analog mulitplexer. each pad input signal is buffered to the digital port register. table 12-23. external trigger control bits etrigle etrigp etrige scan description x x 0 0 ignores external trigger. performs one conversion sequence and stops. x x 0 1 ignores external trigger. performs continuous conversion sequences. 0 0 1 x trigger falling edge sensitive. performs one conversion sequence per trigger. 0 1 1 x trigger rising edge sensitive. performs one conversion sequence per trigger. 1 0 1 x trigger low level sensitive. performs continuous conversions while trigger level is active. 1 1 1 x trigger high level sensitive. performs continuous conversions while trigger level is active.
analog-to-digital converter (adc12b8cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 467 this buffer can be turned on or off with the atddien register for each atd input pin. this is important so that the buffer does not draw excess current when an atd input pin is selected as analog input to the adc12b8c. 12.5 resets at reset the adc12b8c is in a power down state. the reset state of each individual bit is listed within the register description section (see section 12.3.2, ?egister descriptions ) which details the registers and their bit-?ld. 12.6 interrupts the interrupts requested by the adc12b8c are listed in table 12-24 . refer to mcu speci?ation for related vector address and priority. see section 12.3.2, ?egister descriptions for further details. table 12-24. atd interrupt vectors interrupt source ccr mask local enable sequence complete interrupt i bit ascie in atdctl2 compare interrupt i bit acmpie in atdctl2
analog-to-digital converter (adc12b8cv2) mc9s12g family reference manual, rev.1.23 468 freescale semiconductor
mc9s12g family reference manual, rev.1.23 freescale semiconductor 469 chapter 13 analog-to-digital converter (adc10b12cv2) revision history version number revision date effective date author description of changes v02.00 13 may 2009 13 may 2009 initial version copied from v01.06, changed unused bits in atddien to read logic 1 v02.01 30.nov 2009 30.nov 2009 updated table 13-15 analog input channel select coding - description of internal channels. updated register atddr (left/right justi?d result) description in section 13.3.2.12.1/13-489 and 13.3.2.12.2/13-490 and added table table 13-21 to improve feature description. v02.02 09 feb 2010 09 feb 2010 fixed typo in table 13-9 - conversion result for 3mv and 10bit resolution v02.03 26 feb 2010 26 feb 2010 corrected table 13-15 analog input channel select coding - description of internal channels. v02.04 14 apr 2010 14 apr 2010 corrected typos to be in-line with soc level pin naming conventions for vdda, vssa, vrl and vrh. v02.05 25 aug 2010 25 aug 2010 removed feature of conversion during stop and general wording clean up done in section 13.4, ?unctional description v02.06 09 sep 2010 09 sep 2010 update of internal only information. v02.07 11 feb 2011 11 feb 2011 connectivity information regarding internal channel_6 added to table 13-15 . v02.08 29 mar 2011 29 mar 2011 fixed typo in bit description ?ld table 13-14 for bits cd, cc, cb, ca. last sentence contained a wrong highest channel number (it is not an7 to an0 instead it is an11 to an0). v02.09 22. jun 2012 22. jun 2012 update of register write access information in section 13.3.2.9/13-487 . v02.10 29 jun 2012 29. jun 2012 removed ip name in block diagram figure 13-1 v02.11 02 oct 2012 02 oct 2012 added user information to avoid maybe false external trigger events when enabling the external trigger mode ( section 13.4.2.1, ?xternal trigger input ).
analog-to-digital converter (adc10b12cv2) mc9s12g family reference manual, rev.1.23 470 freescale semiconductor 13.1 introduction the adc10b12c is a 12-channel, 10-bit, multiplexed input successive approximation analog-to-digital converter. refer to device electrical speci?ations for atd accuracy. 13.1.1 features 8-, 10-bit resolution. automatic return to low power after conversion sequence automatic compare with interrupt for higher than or less/equal than programmable value programmable sample time. left/right justi?d result data. external trigger control. sequence complete interrupt. analog input multiplexer for 8 analog input channels. special conversions for vrh, vrl, (vrl+vrh)/2 and adc temperature sensor. 1-to-12 conversion sequence lengths. continuous conversion mode. multiple channel scans. con?urable external trigger functionality on any ad channel or any of four additional trigger inputs. the four additional trigger inputs can be chip external or internal. refer to device speci?ation for availability and connectivity. con?urable location for channel wrap around (when converting multiple channels in a sequence).
analog-to-digital converter (adc10b12cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 471 13.1.2 modes of operation 13.1.2.1 conversion modes there is software programmable selection between performing single or continuous conversion on a single channel or multiple channels . 13.1.2.2 mcu operating modes stop mode entering stop mode aborts any conversion sequence in progress and if a sequence was aborted restarts it after exiting stop mode. this has the same effect/consequences as starting a conversion sequence with write to atdctl5. so after exiting from stop mode with a previously aborted sequence all ?gs are cleared etc. wait mode adc10b12c behaves same in run and wait mode. for reduced power consumption continuous conversions should be aborted before entering wait mode. freeze mode in freeze mode the adc10b12c will either continue or ?ish or stop converting according to the frz1 and frz0 bits. this is useful for debugging and emulation.
analog-to-digital converter (adc10b12cv2) mc9s12g family reference manual, rev.1.23 472 freescale semiconductor 13.1.3 block diagram figure 13-1. adc10b12c block diagram vssa an6 analog mux mode and successive approximation register (sar) results atd 0 atd 1 atd 2 atd 3 atd 4 atd 5 atd 6 atd 7 and dac sample & hold vdda vrl vrh sequence complete + - comparator clock prescaler bus clock atd clock an5 an4 an3 an1 an0 an7 etrig0 (see device speci? cation for availability etrig1 etrig2 etrig3 and connectivity) timing control atddien atdctl1 trigger mux interrupt compare interrupt an2 an8 an9 an10 an11 atd 8 atd 9 atd 10 atd 11
analog-to-digital converter (adc10b12cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 473 13.2 signal description this section lists all inputs to the adc10b12c block. 13.2.1 detailed signal descriptions 13.2.1.1 an x ( x = 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) this pin serves as the analog input channel x . it can also be con?ured as digital port or external trigger for the atd conversion. 13.2.1.2 etrig3, etrig2, etrig1, etrig0 these inputs can be con?ured to serve as an external trigger for the atd conversion. refer to device speci?ation for availability and connectivity of these inputs! 13.2.1.3 vrh, vrl vrh is the high reference voltage, vrl is the low reference voltage for atd conversion. 13.2.1.4 vdda, vssa these pins are the power supplies for the analog circuitry of the adc10b12c block. 13.3 memory map and register de?ition this section provides a detailed description of all registers accessible in the adc10b12c. 13.3.1 module memory map figure 13-2 gives an overview on all adc10b12c registers. note register address = base address + address offset, where the base address is de?ed at the mcu level and the address offset is de?ed at the module level. address name bit 7 6 5 4 3 2 1 bit 0 0x0000 atdctl0 r reserved 000 wrap3 wrap2 wrap1 wrap0 w 0x0001 atdctl1 r etrigsel sres1 sres0 smp_dis etrigch3 etrigch2 etrigch1 etrigch0 w 0x0002 atdctl2 r0 affc reserved etrigle etrigp etrige ascie acmpie w = unimplemented or reserved figure 13-2. adc10b12c register summary (sheet 1 of 3)
analog-to-digital converter (adc10b12cv2) mc9s12g family reference manual, rev.1.23 474 freescale semiconductor 0x0003 atdctl3 r djm s8c s4c s2c s1c fifo frz1 frz0 w 0x0004 atdctl4 r smp2 smp1 smp0 prs[4:0] w 0x0005 atdctl5 r0 sc scan mult cd cc cb ca w 0x0006 atdstat0 r scf 0 etorf fifor cc3 cc2 cc1 cc0 w 0x0007 unimple- mented r0 000 0 0 0 0 w 0x0008 atdcmpeh r0 000 cmpe[11:8] w 0x0009 atdcmpel r cmpe[7:0] w 0x000a atdstat2h r 0 0 0 0 ccf[11:8] w 0x000b atdstat2l r ccf[7:0] w 0x000c atddienh r1 111 ien[11:8] w 0x000d atddienl r ien[7:0] w 0x000e atdcmphth r0 000 cmpht[11:8] w 0x000f atdcmphtl r cmpht[7:0] w 0x0010 atddr0 r see section 13.3.2.12.1, ?eft justi?d result data (djm=0) and section 13.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0012 atddr1 r see section 13.3.2.12.1, ?eft justi?d result data (djm=0) and section 13.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0014 atddr2 r see section 13.3.2.12.1, ?eft justi?d result data (djm=0) and section 13.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0016 atddr3 r see section 13.3.2.12.1, ?eft justi?d result data (djm=0) and section 13.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0018 atddr4 r see section 13.3.2.12.1, ?eft justi?d result data (djm=0) and section 13.3.2.12.2, ?ight justi?d result data (djm=1) w 0x001a atddr5 r see section 13.3.2.12.1, ?eft justi?d result data (djm=0) and section 13.3.2.12.2, ?ight justi?d result data (djm=1) w 0x001c atddr6 r see section 13.3.2.12.1, ?eft justi?d result data (djm=0) and section 13.3.2.12.2, ?ight justi?d result data (djm=1) w 0x001e atddr7 r see section 13.3.2.12.1, ?eft justi?d result data (djm=0) and section 13.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0020 atddr8 r see section 13.3.2.12.1, ?eft justi?d result data (djm=0) and section 13.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0022 atddr9 r see section 13.3.2.12.1, ?eft justi?d result data (djm=0) and section 13.3.2.12.2, ?ight justi?d result data (djm=1) w address name bit 7 6 5 4 3 2 1 bit 0 = unimplemented or reserved figure 13-2. adc10b12c register summary (sheet 2 of 3)
analog-to-digital converter (adc10b12cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 475 0x0024 atddr10 r see section 13.3.2.12.1, ?eft justi?d result data (djm=0) and section 13.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0026 atddr11 r see section 13.3.2.12.1, ?eft justi?d result data (djm=0) and section 13.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0028 - 0x002f unimple- mented r 00000000 w address name bit 7 6 5 4 3 2 1 bit 0 = unimplemented or reserved figure 13-2. adc10b12c register summary (sheet 3 of 3)
analog-to-digital converter (adc10b12cv2) mc9s12g family reference manual, rev.1.23 476 freescale semiconductor 13.3.2 register descriptions this section describes in address order all the adc10b12c registers and their individual bits. 13.3.2.1 atd control register 0 (atdctl0) writes to this register will abort current conversion sequence. read: anytime write: anytime, in special modes always write 0 to reserved bit 7. module base + 0x0000 76543210 r reserved 000 wrap3 wrap2 wrap1 wrap0 w reset 0 0 0 01111 = unimplemented or reserved figure 13-3. atd control register 0 (atdctl0) table 13-1. atdctl0 field descriptions field description 3-0 wrap[3-0] wrap around channel select bits ?these bits determine the channel for wrap around when doing multi-channel conversions. the coding is summarized in table 13-2 . table 13-2. multi-channel wrap around coding wrap3 wrap2 wrap1 wrap0 multiple channel conversions (mult = 1) wraparound to an0 after converting 0000 reserved 1 0001 an1 0010 an2 0011 an3 0100 an4 0101 an5 0110 an6 0111 an7 1000 an8 1001 an9 1010 an10 1011 an11 1100 an11 1101 an11 1110 an11 1111 an11
analog-to-digital converter (adc10b12cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 477 13.3.2.2 atd control register 1 (atdctl1) writes to this register will abort current conversion sequence. read: anytime write: anytime 1 if only an0 should be converted use mult=0. module base + 0x0001 76543210 r etrigsel sres1 sres0 smp_dis etrigch3 etrigch2 etrigch1 etrigch0 w reset 0 0 1 01111 figure 13-4. atd control register 1 (atdctl1) table 13-3. atdctl1 field descriptions field description 7 etrigsel external trigger source select ?this bit selects the external trigger source to be either one of the ad channels or one of the etrig3-0 inputs. see device speci?ation for availability and connectivity of etrig3-0 inputs. if a particular etrig3-0 input option is not available, writing a 1 to etrisel only sets the bit but has no effect, this means that one of the ad channels (selected by etrigch3-0) is con?ured as the source for external trigger. the coding is summarized in table 13-5 . 6? sres[1:0] a/d resolution select ?these bits select the resolution of a/d conversion results. see table 13-4 for coding. 4 smp_dis discharge before sampling bit 0 no discharge before sampling. 1 the internal sample capacitor is discharged before sampling the channel. this adds 2 atd clock cycles to the sampling time. this can help to detect an open circuit instead of measuring the previous sampled channel. 3? etrigch[3:0] external trigger channel select these bits select one of the ad channels or one of the etrig3-0 inputs as source for the external trigger. the coding is summarized in table 13-5 . table 13-4. a/d resolution coding sres1 sres0 a/d resolution 0 0 8-bit data 0 1 10-bit data 1 0 reserved 1 1 reserved
analog-to-digital converter (adc10b12cv2) mc9s12g family reference manual, rev.1.23 478 freescale semiconductor 13.3.2.3 atd control register 2 (atdctl2) writes to this register will abort current conversion sequence. read: anytime write: anytime table 13-5. external trigger channel select coding etrigsel etrigch3 etrigch2 etrigch1 etrigch0 external trigger source is 0 0 0 0 0 an0 0 0 0 0 1 an1 0 0 0 1 0 an2 0 0 0 1 1 an3 0 0 1 0 0 an4 0 0 1 0 1 an5 0 0 1 1 0 an6 0 0 1 1 1 an7 0 1 0 0 0 an8 0 1 0 0 1 an9 0 1 0 1 0 an10 0 1 0 1 1 an11 0 1 1 0 0 an11 0 1 1 0 1 an11 0 1 1 1 0 an11 0 1 1 1 1 an11 1 0 0 0 0 etrig0 1 1 only if etrig3-0 input option is available (see device speci?ation), else etrisel is ignored, that means external trigger source is still on one of the ad channels selected by etrigch3-0 1 0 0 0 1 etrig1 1 1 0 0 1 0 etrig2 1 1 0 0 1 1 etrig3 1 1 0 1 x x reserved 1 1 x x x reserved module base + 0x0002 76543210 r0 affc reserved etrigle etrigp etrige ascie acmpie w reset 0 0 0 00000 = unimplemented or reserved figure 13-5. atd control register 2 (atdctl2)
analog-to-digital converter (adc10b12cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 479 table 13-6. atdctl2 field descriptions field description 6 affc atd fast flag clear all 0 atd ?g clearing done by write 1 to respective ccf[ n ] ?g. 1 changes all atd conversion complete ?gs to a fast clear sequence. for compare disabled (cmpe[ n ]=0) a read access to the result register will cause the associated ccf[ n ] ?g to clear automatically. for compare enabled (cmpe[ n ]=1) a write access to the result register will cause the associated ccf[ n ] ?g to clear automatically. 5 reserved do not alter this bit from its reset value.it is for manufacturer use only and can change the atd behavior. 4 etrigle external trigger level/edge control ?this bit controls the sensitivity of the external trigger signal. see table 13-7 for details. 3 etrigp external trigger polarity this bit controls the polarity of the external trigger signal. see table 13-7 for details. 2 etrige external trigger mode enable this bit enables the external trigger on one of the ad channels or one of the etrig3-0 inputs as described in table 13-5 . if the external trigger source is one of the ad channels, the digital input buffer of this channel is enabled. the external trigger allows to synchronize the start of conversion with external events. 0 disable external trigger 1 enable external trigger 1 ascie atd sequence complete interrupt enable 0 atd sequence complete interrupt requests are disabled. 1 atd sequence complete interrupt will be requested whenever scf=1 is set. 0 acmpie atd compare interrupt enable if automatic compare is enabled for conversion n (cmpe[ n ]=1 in atdcmpe register) this bit enables the compare interrupt. if the ccf[ n ] ?g is set (showing a successful compare for conversion n ), the compare interrupt is triggered. 0 atd compare interrupt requests are disabled. 1 for the conversions in a sequence for which automatic compare is enabled (cmpe[ n ]=1), an atd compare interrupt will be requested whenever any of the respective ccf ?gs is set. table 13-7. external trigger con?urations etrigle etrigp external trigger sensitivity 0 0 falling edge 0 1 rising edge 1 0 low level 1 1 high level
analog-to-digital converter (adc10b12cv2) mc9s12g family reference manual, rev.1.23 480 freescale semiconductor 13.3.2.4 atd control register 3 (atdctl3) writes to this register will abort current conversion sequence. read: anytime write: anytime module base + 0x0003 76543210 r djm s8c s4c s2c s1c fifo frz1 frz0 w reset 0 0 1 00000 = unimplemented or reserved figure 13-6. atd control register 3 (atdctl3) table 13-8. atdctl3 field descriptions field description 7 djm result register data justi?ation ?result data format is always unsigned. this bit controls justi?ation of conversion data in the result registers. 0 left justi?d data in the result registers. 1 right justi?d data in the result registers. table 13-9 gives example atd results for an input signal range between 0 and 5.12 volts. 6? s8c, s4c, s2c, s1c conversion sequence length ?these bits control the number of conversions per sequence. table 13-10 shows all combinations. at reset, s4c is set to 1 (sequence length is 4). this is to maintain software continuity to hc12 family. 2 fifo result register fifo mode if this bit is zero (non-fifo mode), the a/d conversion results map into the result registers based on the conversion sequence; the result of the ?st conversion appears in the ?st result register (atddr0), the second result in the second result register (atddr1), and so on. if this bit is one (fifo mode) the conversion counter is not reset at the beginning or end of a conversion sequence; sequential conversion results are placed in consecutive result registers. in a continuously scanning conversion sequence, the result register counter will wrap around when it reaches the end of the result register ?e. the conversion counter value (cc3-0 in atdstat0) can be used to determine where in the result register ?e, the current conversion result will be placed. aborting a conversion or starting a new conversion clears the conversion counter even if fifo=1. so the ?st result of a new conversion sequence, started by writing to atdctl5, will always be place in the ?st result register (atdddr0). intended usage of fifo mode is continuos conversion (scan=1) or triggered conversion (etrig=1). which result registers hold valid data can be tracked using the conversion complete ?gs. fast ?g clear mode may be useful in a particular application to track valid data. if this bit is one, automatic compare of result registers is always disabled, that is adc10b12c will behave as if acmpie and all cpme[ n ] were zero. 0 conversion results are placed in the corresponding result register up to the selected sequence length. 1 conversion results are placed in consecutive result registers (wrap around at end). 1? frz[1:0] background debug freeze enable ?when debugging an application, it is useful in many cases to have the atd pause when a breakpoint (freeze mode) is encountered. these 2 bits determine how the atd will respond to a breakpoint as shown in table 13-11 . leakage onto the storage node and comparator reference capacitors may compromise the accuracy of an immediately frozen conversion depending on the length of the freeze period.
analog-to-digital converter (adc10b12cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 481 table 13-9. examples of ideal decimal atd results input signal vrl = 0 volts vrh = 5.12 volts 8-bit codes (resolution=20mv) 10-bit codes (resolution=5mv) reserved 5.120 volts ... 0.022 0.020 0.018 0.016 0.014 0.012 0.010 0.008 0.006 0.004 0.003 0.002 0.000 255 ... 1 1 1 1 1 1 1 0 0 0 0 0 0 1023 ... 4 4 4 3 3 2 2 2 1 1 1 0 0 reserved table 13-10. conversion sequence length coding s8c s4c s2c s1c number of conversions per sequence 00 0 0 12 00 0 1 1 00 1 0 2 00 1 1 3 01 0 0 4 01 0 1 5 01 1 0 6 01 1 1 7 10 0 0 8 10 0 1 9 10 1 0 10 10 1 1 11 11 0 0 12 11 0 1 12 11 1 0 12 11 1 1 12 table 13-11. atd behavior in freeze mode (breakpoint) frz1 frz0 behavior in freeze mode 0 0 continue conversion
analog-to-digital converter (adc10b12cv2) mc9s12g family reference manual, rev.1.23 482 freescale semiconductor 13.3.2.5 atd control register 4 (atdctl4) writes to this register will abort current conversion sequence. read: anytime write: anytime 0 1 reserved 1 0 finish current conversion, then freeze 1 1 freeze immediately module base + 0x0004 76543210 r smp2 smp1 smp0 prs[4:0] w reset 0 0 0 00101 figure 13-7. atd control register 4 (atdctl4) table 13-12. atdctl4 field descriptions field description 7? smp[2:0] sample time select ?these three bits select the length of the sample time in units of atd conversion clock cycles. note that the atd conversion clock period is itself a function of the prescaler value (bits prs4-0). table 13-13 lists the available sample time lengths. 4? prs[4:0] atd clock prescaler these 5 bits are the binary prescaler value prs. the atd conversion clock frequency is calculated as follows: refer to device speci?ation for allowed frequency range of f atdclk . table 13-13. sample time select smp2 smp1 smp0 sample time in number of atd clock cycles 000 4 001 6 010 8 011 10 100 12 101 16 110 20 111 24 table 13-11. atd behavior in freeze mode (breakpoint) frz1 frz0 behavior in freeze mode f atdclk f bus 2 prs 1 + () ------------------------------------- =
analog-to-digital converter (adc10b12cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 483 13.3.2.6 atd control register 5 (atdctl5) writes to this register will abort current conversion sequence and start a new conversion sequence. if the external trigger function is enabled (etrige=1) an initial write to atdctl5 is required to allow starting of a conversion sequence which will then occur on each trigger event. start of conversion means the beginning of the sampling phase. read: anytime write: anytime module base + 0x0005 76543210 r0 sc scan mult cd cc cb ca w reset 0 0 0 00000 = unimplemented or reserved figure 13-8. atd control register 5 (atdctl5) table 13-14. atdctl5 field descriptions field description 6 sc special channel conversion bit if this bit is set, then special channel conversion can be selected using cd, cc, cb and ca of atdctl5. table 13-15 lists the coding. 0 special channel conversions disabled 1 special channel conversions enabled 5 scan continuous conversion sequence mode ?this bit selects whether conversion sequences are performed continuously or only once. if the external trigger function is enabled (etrige=1) setting this bit has no effect, thus the external trigger always starts a single conversion sequence. 0 single conversion sequence 1 continuous conversion sequences (scan mode) 4 mult multi-channel sample mode when mult is 0, the atd sequence controller samples only from the speci?d analog input channel for an entire conversion sequence. the analog channel is selected by channel selection code (control bits cd/cc/cb/ca located in atdctl5). when mult is 1, the atd sequence controller samples across channels. the number of channels sampled is determined by the sequence length value (s8c, s4c, s2c, s1c). the ?st analog channel examined is determined by channel selection code (cd, cc, cb, ca control bits); subsequent channels sampled in the sequence are determined by incrementing the channel selection code or wrapping around to an0 (channel 0). 0 sample only one channel 1 sample across several channels 3? cd, cc, cb, ca analog input channel select code ?these bits select the analog input channel(s). table 13-15 lists the coding used to select the various analog input channels. in the case of single channel conversions (mult=0), this selection code speci?s the channel to be examined. in the case of multiple channel conversions (mult=1), this selection code speci?s the ?st channel to be examined in the conversion sequence. subsequent channels are determined by incrementing the channel selection code or wrapping around to an0 (after converting the channel de?ed by the wrap around channel select bits wrap3-0 in atdctl0). when starting with a channel number higher than the one de?ed by wrap3-0 the ?st wrap around will be an11 to an0.
analog-to-digital converter (adc10b12cv2) mc9s12g family reference manual, rev.1.23 484 freescale semiconductor table 13-15. analog input channel select coding sc cd cc cb ca analog input channel 00000 an0 0001 an1 0010 an2 0011 an3 0100 an4 0101 an5 0110 an6 0111 an7 1000 an8 1001 an9 1 0 1 0 an10 1 0 1 1 an11 1 1 0 0 an11 1 1 0 1 an11 1 1 1 0 an11 1 1 1 1 an11 1 0 0 0 0 internal_6, temperature sense of adc hardmacro 0 0 0 1 internal_7 0 0 1 0 internal_0 0 0 1 1 internal_1 0100 vrh 0101 vrl 0 1 1 0 (vrh+vrl) / 2 0 1 1 1 reserved 1 0 0 0 internal_2 1 0 0 1 internal_3 1 0 1 0 internal_4 1 0 1 1 internal_5 1 1 x x reserved
analog-to-digital converter (adc10b12cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 485 13.3.2.7 atd status register 0 (atdstat0) this register contains the sequence complete flag, overrun ?gs for external trigger and fifo mode, and the conversion counter. read: anytime write: anytime (no effect on (cc3, cc2, cc1, cc0)) module base + 0x0006 76543210 r scf 0 etorf fifor cc3 cc2 cc1 cc0 w reset 0 0 0 00000 = unimplemented or reserved figure 13-9. atd status register 0 (atdstat0) table 13-16. atdstat0 field descriptions field description 7 scf sequence complete flag ?this ?g is set upon completion of a conversion sequence. if conversion sequences are continuously performed (scan=1), the ?g is set after each one is completed. this ?g is cleared when one of the following occurs: a) write ??to scf b) write to atdctl5 (a new conversion sequence is started) c) if affc=1 and a result register is read 0 conversion sequence not completed 1 conversion sequence has completed 5 etorf external trigger overrun flag ?while in edge sensitive mode (etrigle=0), if additional active edges are detected while a conversion sequence is in process the overrun ?g is set. this ?g is cleared when one of the following occurs: a) write ??to etorf b) write to atdctl0,1,2,3,4, atdcmpe or atdcmpht (a conversion sequence is aborted) c) write to atdctl5 (a new conversion sequence is started) 0 no external trigger overrun error has occurred 1 external trigger overrun error has occurred 4 fifor result register overrun flag this bit indicates that a result register has been written to before its associated conversion complete ?g (ccf) has been cleared. this ?g is most useful when using the fifo mode because the ?g potentially indicates that result registers are out of sync with the input channels. however, it is also practical for non-fifo modes, and indicates that a result register has been overwritten before it has been read (i.e. the old data has been lost). this ?g is cleared when one of the following occurs: a) write ??to fifor b) write to atdctl0,1,2,3,4, atdcmpe or atdcmpht (a conversion sequence is aborted) c) write to atdctl5 (a new conversion sequence is started) 0 no overrun has occurred 1 overrun condition exists (result register has been written while associated ccfx ?g was still set)
analog-to-digital converter (adc10b12cv2) mc9s12g family reference manual, rev.1.23 486 freescale semiconductor 13.3.2.8 atd compare enable register (atdcmpe) writes to this register will abort current conversion sequence. read: anytime write: anytime 3? cc[3:0] conversion counter these 4 read-only bits are the binary value of the conversion counter. the conversion counter points to the result register that will receive the result of the current conversion. e.g. cc3=0, cc2=1, cc1=1, cc0=0 indicates that the result of the current conversion will be in atd result register 6. if in non-fifo mode (fifo=0) the conversion counter is initialized to zero at the beginning and end of the conversion sequence. if in fifo mode (fifo=1) the register counter is not initialized. the conversion counter wraps around when its maximum value is reached. aborting a conversion or starting a new conversion clears the conversion counter even if fifo=1. module base + 0x0008 15 14 13 11 10 9 8 7 6 5 4 3 2 1 0 r 0 0 0 0 cmpe[11:0] w reset 0 0 0 0 0 0 0 0 0 0000000 = unimplemented or reserved figure 13-10. atd compare enable register (atdcmpe) table 13-17. atdcmpe field descriptions field description 11? cmpe[11:0] compare enable for conversion number n ( n = 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) of a sequence ( n conversion number, not channel number!) these bits enable automatic compare of conversion results individually for conversions of a sequence. the sense of each comparison is determined by the cmpht[ n ] bit in the atdcmpht register. for each conversion number with cmpe[ n ]=1 do the following: 1) write compare value to atddr n result register 2) write compare operator with cmpht[ n ] in atdcpmht register ccf[ n ] in atdstat2 register will ?g individual success of any comparison. 0 no automatic compare 1 automatic compare of results for conversion n of a sequence is enabled. table 13-16. atdstat0 field descriptions (continued) field description
analog-to-digital converter (adc10b12cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 487 13.3.2.9 atd status register 2 (atdstat2) this read-only register contains the conversion complete flags ccf[11:0]. read: anytime write: anytime (for details see table 13-18 below) module base + 0x000a 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r 0 0 0 0 ccf[11:0] w reset 0 0 0 0 0 0 0 0 0 0000000 = unimplemented or reserved figure 13-11. atd status register 2 (atdstat2) table 13-18. atdstat2 field descriptions field description 11? ccf[11:0] conversion complete flag n ( n = 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) ( n conversion number, not channel number!) ?a conversion complete ?g is set at the end of each conversion in a sequence. the ?gs are associated with the conversion position in a sequence (and also the result register number). therefore in non-?o mode, ccf[4] is set when the ?th conversion in a sequence is complete and the result is available in result register atddr4; ccf[5] is set when the sixth conversion in a sequence is complete and the result is available in atddr5, and so forth. if automatic compare of conversion results is enabled (cmpe[ n ]=1 in atdcmpe), the conversion complete ?g is only set if comparison with atddr n is true. if acmpie=1 a compare interrupt will be requested. in this case, as the atddr n result register is used to hold the compare value, the result will not be stored there at the end of the conversion but is lost. a ?g ccf[ n ] is cleared when one of the following occurs: a) write to atdctl5 (a new conversion sequence is started) b) if affc=0, write ??to ccf[ n ] c) if affc=1 and cmpe[ n ]=0, read of result register atddr n d) if affc=1 and cmpe[ n ]=1, write to result register atddr n in case of a concurrent set and clear on ccf[ n ]: the clearing by method a) will overwrite the set. the clearing by methods b) or c) or d) will be overwritten by the set. 0 conversion number n not completed or successfully compared 1 if (cmpe[ n ]=0): conversion number n has completed. result is ready in atddr n . if (cmpe[ n ]=1): compare for conversion result number n with compare value in atddr n , using compare operator cmpgt[ n ] is true. (no result available in atddr n )
analog-to-digital converter (adc10b12cv2) mc9s12g family reference manual, rev.1.23 488 freescale semiconductor 13.3.2.10 atd input enable register (atddien) read: anytime write: anytime 13.3.2.11 atd compare higher than register (atdcmpht) writes to this register will abort current conversion sequence. read: anytime write: anytime module base + 0x000c 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r 1 1 1 1 ien[11:0] w reset 1 1 1 1 0 0 0 0 0 0000000 = unimplemented or reserved figure 13-12. atd input enable register (atddien) table 13-19. atddien field descriptions field description 11? ien[11:0] atd digital input enable on channel x ( x = 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) this bit controls the digital input buffer from the analog input pin (an x ) to the digital data register. 0 disable digital input buffer to an x pin 1 enable digital input buffer on an x pin. note: setting this bit will enable the corresponding digital input buffer continuously. if this bit is set while simultaneously using it as an analog port, there is potentially increased power consumption because the digital input buffer maybe in the linear region. module base + 0x000e 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r 0 0 0 0 cmpht[11:0] w reset 0 0 0 0 0 0 0 0 0 0000000 = unimplemented or reserved figure 13-13. atd compare higher than register (atdcmpht) table 13-20. atdcmpht field descriptions field description 11? cmpht[11:0] compare operation higher than enable for conversion number n ( n = 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) of a sequence ( n conversion number, not channel number!) this bit selects the operator for comparison of conversion results. 0 if result of conversion n is lower or same than compare value in atddr n , this is ?gged in atdstat2 1 if result of conversion n is higher than compare value in atddr n , this is ?gged in atdstat2
analog-to-digital converter (adc10b12cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 489 13.3.2.12 atd conversion result registers (atddr n ) the a/d conversion results are stored in 12 result registers. results are always in unsigned data representation. left and right justi?ation is selected using the djm control bit in atdctl3. if automatic compare of conversions results is enabled (cmpe[ n ]=1 in atdcmpe), these registers must be written with the compare values in left or right justi?d format depending on the actual value of the djm bit. in this case, as the atddr n register is used to hold the compare value, the result will not be stored there at the end of the conversion but is lost. attention, n is the conversion number, not the channel number! read: anytime write: anytime note for conversions not using automatic compare, results are stored in the result registers after each conversion. in this case avoid writing to atddrn except for initial values, because an a/d result might be overwritten. 13.3.2.12.1 left justi?d result data (djm=0) table 13-21 shows how depending on the a/d resolution the conversion result is transferred to the atd result registers for left justi?d data. compare is always done using all 12 bits of both the conversion result and the compare value in atddrn. table 13-21. conversion result mapping to atddrn module base + 0x0010 = atddr0, 0x0012 = atddr1, 0x0014 = atddr2, 0x0016 = atddr3 0x0018 = atddr4, 0x001a = atddr5, 0x001c = atddr6, 0x001e = atddr7 0x0020 = atddr8, 0x0022 = atddr9, 0x0024 = atddr10, 0x0026 = atddr11 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r result-bit[11:0] 0 000 w reset 0 0 0 0 0 0 0 0 0 0000000 = unimplemented or reserved figure 13-14. left justi?d atd conversion result register (atddr n ) a/d resolution djm conversion result mapping to atddr n 8-bit data 0 result-bit[11:4] = conversion result, result-bit[3:0]=0000 10-bit data 0 result-bit[11:2] = conversion result, result-bit[1:0]=00
analog-to-digital converter (adc10b12cv2) mc9s12g family reference manual, rev.1.23 490 freescale semiconductor 13.3.2.12.2 right justi?d result data (djm=1) table 13-22 shows how depending on the a/d resolution the conversion result is transferred to the atd result registers for right justi?d data. compare is always done using all 12 bits of both the conversion result and the compare value in atddrn. module base + 0x0010 = atddr0, 0x0012 = atddr1, 0x0014 = atddr2, 0x0016 = atddr3 0x0018 = atddr4, 0x001a = atddr5, 0x001c = atddr6, 0x001e = atddr7 0x0020 = atddr8, 0x0022 = atddr9, 0x0024 = atddr10, 0x0026 = atddr11 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r 0 000 result-bit[11:0] w reset 0 0 0 0 0 0 0 0 0 0000000 = unimplemented or reserved figure 13-15. right justi?d atd conversion result register (atddr n ) table 13-22. conversion result mapping to atddrn a/d resolution djm conversion result mapping to atddr n 8-bit data 1 result-bit[11:8]=0000, result-bit[7:0] = conversion result 10-bit data 1 result-bit[11:10]=00, result-bit[9:0] = conversion result
analog-to-digital converter (adc10b12cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 491 13.4 functional description the adc10b12c consists of an analog sub-block and a digital sub-block. 13.4.1 analog sub-block the analog sub-block contains all analog electronics required to perform a single conversion. separate power supplies vdda and vssa allow to isolate noise of other mcu circuitry from the analog sub-block. 13.4.1.1 sample and hold machine the sample and hold machine controls the storage and charge of the sample capacitor to the voltage level of the analog signal at the selected adc input channel. during the sample process the analog input connects directly to the storage node. the input analog signals are unipolar and must be within the potential range of vssa to vdda. during the hold process the analog input is disconnected from the storage node. 13.4.1.2 analog input multiplexer the analog input multiplexer connects one of the 12 external analog input channels to the sample and hold machine. 13.4.1.3 analog-to-digital (a/d) machine the a/d machine performs analog to digital conversions. the resolution is program selectable to be either 8 or 10 bits. the a/d machine uses a successive approximation architecture. it functions by comparing the sampled and stored analog voltage with a series of binary coded discrete voltages. by following a binary search algorithm, the a/d machine identi?s the discrete voltage that is nearest to the sampled and stored voltage. when not converting the a/d machine is automatically powered down. only analog input signals within the potential range of vrl to vrh (a/d reference potentials) will result in a non-railed digital output code. 13.4.2 digital sub-block this subsection describes some of the digital features in more detail. see section 13.3.2, ?egister descriptions for all details. 13.4.2.1 external trigger input the external trigger feature allows the user to synchronize atd conversions to an external event rather than relying only on software to trigger the atd module when a conversions is about to take place. the external trigger signal (out of reset atd channel 11, con?urable in atdctl1) is programmable to be
analog-to-digital converter (adc10b12cv2) mc9s12g family reference manual, rev.1.23 492 freescale semiconductor edge or level sensitive with polarity control. table 13-23 gives a brief description of the different combinations of control bits and their effect on the external trigger function. in order to avoid maybe false trigger events please enable the external digital input via atddien register ?st and in the following enable the external trigger mode by bit etrige. in either level or edge sensitive modes, the ?st conversion begins when the trigger is received. once etrige is enabled a conversion must be triggered externally after writing to atdctl5 register. during a conversion in edge sensitive mode, if additional trigger events are detected the overrun error ?g etorf is set. if level sensitive mode is active and the external trigger de-asserts and later asserts again during a conversion sequence, this does not constitute an overrun. therefore, the ?g is not set. if the trigger is left active in level sensitive mode when a sequence is about to complete, another sequence will be triggered immediately. 13.4.2.2 general-purpose digital port operation each atd input pin can be switched between analog or digital input functionality. an analog multiplexer makes each atd input pin selected as analog input available to the a/d converter. the pad of the atd input pin is always connected to the analog input channel of the analog mulitplexer. each pad input signal is buffered to the digital port register. this buffer can be turned on or off with the atddien register for each atd input pin. this is important so that the buffer does not draw excess current when an atd input pin is selected as analog input to the adc10b12c. table 13-23. external trigger control bits etrigle etrigp etrige scan description x x 0 0 ignores external trigger. performs one conversion sequence and stops. x x 0 1 ignores external trigger. performs continuous conversion sequences. 0 0 1 x trigger falling edge sensitive. performs one conversion sequence per trigger. 0 1 1 x trigger rising edge sensitive. performs one conversion sequence per trigger. 1 0 1 x trigger low level sensitive. performs continuous conversions while trigger level is active. 1 1 1 x trigger high level sensitive. performs continuous conversions while trigger level is active.
analog-to-digital converter (adc10b12cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 493 13.5 resets at reset the adc10b12c is in a power down state. the reset state of each individual bit is listed within the register description section (see section 13.3.2, ?egister descriptions ) which details the registers and their bit-?ld. 13.6 interrupts the interrupts requested by the adc10b12c are listed in table 13-24 . refer to mcu speci?ation for related vector address and priority. see section 13.3.2, ?egister descriptions for further details. table 13-24. atd interrupt vectors interrupt source ccr mask local enable sequence complete interrupt i bit ascie in atdctl2 compare interrupt i bit acmpie in atdctl2
analog-to-digital converter (adc10b12cv2) mc9s12g family reference manual, rev.1.23 494 freescale semiconductor
mc9s12g family reference manual, rev.1.23 freescale semiconductor 495 chapter 14 analog-to-digital converter (adc12b12cv2) revision history version number revision date effective date author description of changes v02.00 13 may 2009 13 may 2009 initial version copied from v01.06, changed unused bits in atddien to read logic 1 v02.01 30.nov 2009 30.nov 2009 updated table 14-15 analog input channel select coding - description of internal channels. updated register atddr (left/right justi?d result) description in section 14.3.2.12.1/14-516 and 14.3.2.12.2/14-517 and added table table 14-21 to improve feature description. v02.02 09 feb 2010 09 feb 2010 fixed typo in table 14-9 - conversion result for 3mv and 10bit resolution v02.03 26 feb 2010 26 feb 2010 corrected table 14-15 analog input channel select coding - description of internal channels. v02.04 14 apr 2010 14 apr 2010 corrected typos to be in-line with soc level pin naming conventions for vdda, vssa, vrl and vrh. v02.05 25 aug 2010 25 aug 2010 removed feature of conversion during stop and general wording clean up done in section 14.4, ?unctional description v02.06 09 sep 2010 09 sep 2010 update of internal only information. v02.07 11 feb 2011 11 feb 2011 connectivity information regarding internal channel_6 added to table 14-15 . v02.08 29 mar 2011 29 mar 2011 fixed typo in bit description ?ld table 14-14 for bits cd, cc, cb, ca. last sentence contained a wrong highest channel number (it is not an7 to an0 instead it is an11 to an0). v02.09 22. jun 2012 22. jun 2012 update of register write access information in section 14.3.2.9/14-514 . v02.10 29 jun 2012 29. jun 2012 removed ip name in block diagram figure 14-1 v02.11 02 oct 2012 02 oct 2012 added user information to avoid maybe false external trigger events when enabling the external trigger mode ( section 14.4.2.1, ?xternal trigger input ).
analog-to-digital converter (adc12b12cv2) mc9s12g family reference manual, rev.1.23 496 freescale semiconductor 14.1 introduction the adc12b12c is a 12-channel, 12-bit, multiplexed input successive approximation analog-to-digital converter. refer to device electrical speci?ations for atd accuracy. 14.1.1 features 8-, 10-, or 12-bit resolution. automatic return to low power after conversion sequence automatic compare with interrupt for higher than or less/equal than programmable value programmable sample time. left/right justi?d result data. external trigger control. sequence complete interrupt. analog input multiplexer for 8 analog input channels. special conversions for vrh, vrl, (vrl+vrh)/2 and adc temperature sensor. 1-to-12 conversion sequence lengths. continuous conversion mode. multiple channel scans. con?urable external trigger functionality on any ad channel or any of four additional trigger inputs. the four additional trigger inputs can be chip external or internal. refer to device speci?ation for availability and connectivity. con?urable location for channel wrap around (when converting multiple channels in a sequence).
analog-to-digital converter (adc12b12cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 497 14.1.2 modes of operation 14.1.2.1 conversion modes there is software programmable selection between performing single or continuous conversion on a single channel or multiple channels . 14.1.2.2 mcu operating modes stop mode entering stop mode aborts any conversion sequence in progress and if a sequence was aborted restarts it after exiting stop mode. this has the same effect/consequences as starting a conversion sequence with write to atdctl5. so after exiting from stop mode with a previously aborted sequence all ?gs are cleared etc. wait mode adc12b12c behaves same in run and wait mode. for reduced power consumption continuous conversions should be aborted before entering wait mode. freeze mode in freeze mode the adc12b12c will either continue or ?ish or stop converting according to the frz1 and frz0 bits. this is useful for debugging and emulation.
analog-to-digital converter (adc12b12cv2) mc9s12g family reference manual, rev.1.23 498 freescale semiconductor 14.1.3 block diagram figure 14-1. adc12b12c block diagram vssa an6 analog mux mode and successive approximation register (sar) results atd 0 atd 1 atd 2 atd 3 atd 4 atd 5 atd 6 atd 7 and dac sample & hold vdda vrl vrh sequence complete + - comparator clock prescaler bus clock atd clock an5 an4 an3 an1 an0 an7 etrig0 (see device speci? cation for availability etrig1 etrig2 etrig3 and connectivity) timing control atddien atdctl1 trigger mux interrupt compare interrupt an2 an8 an9 an10 an11 atd 8 atd 9 atd 10 atd 11
analog-to-digital converter (adc12b12cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 499 14.2 signal description this section lists all inputs to the adc12b12c block. 14.2.1 detailed signal descriptions 14.2.1.1 an x ( x = 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) this pin serves as the analog input channel x . it can also be con?ured as digital port or external trigger for the atd conversion. 14.2.1.2 etrig3, etrig2, etrig1, etrig0 these inputs can be con?ured to serve as an external trigger for the atd conversion. refer to device speci?ation for availability and connectivity of these inputs! 14.2.1.3 vrh, vrl vrh is the high reference voltage, vrl is the low reference voltage for atd conversion. 14.2.1.4 vdda, vssa these pins are the power supplies for the analog circuitry of the adc12b12c block. 14.3 memory map and register de?ition this section provides a detailed description of all registers accessible in the adc12b12c. 14.3.1 module memory map figure 14-2 gives an overview on all adc12b12c registers. note register address = base address + address offset, where the base address is de?ed at the mcu level and the address offset is de?ed at the module level. address name bit 7 6 5 4 3 2 1 bit 0 0x0000 atdctl0 r reserved 000 wrap3 wrap2 wrap1 wrap0 w 0x0001 atdctl1 r etrigsel sres1 sres0 smp_dis etrigch3 etrigch2 etrigch1 etrigch0 w 0x0002 atdctl2 r0 affc reserved etrigle etrigp etrige ascie acmpie w = unimplemented or reserved figure 14-2. adc12b12c register summary (sheet 1 of 3)
analog-to-digital converter (adc12b12cv2) mc9s12g family reference manual, rev.1.23 500 freescale semiconductor 0x0003 atdctl3 r djm s8c s4c s2c s1c fifo frz1 frz0 w 0x0004 atdctl4 r smp2 smp1 smp0 prs[4:0] w 0x0005 atdctl5 r0 sc scan mult cd cc cb ca w 0x0006 atdstat0 r scf 0 etorf fifor cc3 cc2 cc1 cc0 w 0x0007 unimple- mented r0 000 0 0 0 0 w 0x0008 atdcmpeh r0 000 cmpe[11:8] w 0x0009 atdcmpel r cmpe[7:0] w 0x000a atdstat2h r 0 0 0 0 ccf[11:8] w 0x000b atdstat2l r ccf[7:0] w 0x000c atddienh r1 111 ien[11:8] w 0x000d atddienl r ien[7:0] w 0x000e atdcmphth r0 000 cmpht[11:8] w 0x000f atdcmphtl r cmpht[7:0] w 0x0010 atddr0 r see section 14.3.2.12.1, ?eft justi?d result data (djm=0) and section 14.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0012 atddr1 r see section 14.3.2.12.1, ?eft justi?d result data (djm=0) and section 14.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0014 atddr2 r see section 14.3.2.12.1, ?eft justi?d result data (djm=0) and section 14.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0016 atddr3 r see section 14.3.2.12.1, ?eft justi?d result data (djm=0) and section 14.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0018 atddr4 r see section 14.3.2.12.1, ?eft justi?d result data (djm=0) and section 14.3.2.12.2, ?ight justi?d result data (djm=1) w 0x001a atddr5 r see section 14.3.2.12.1, ?eft justi?d result data (djm=0) and section 14.3.2.12.2, ?ight justi?d result data (djm=1) w 0x001c atddr6 r see section 14.3.2.12.1, ?eft justi?d result data (djm=0) and section 14.3.2.12.2, ?ight justi?d result data (djm=1) w 0x001e atddr7 r see section 14.3.2.12.1, ?eft justi?d result data (djm=0) and section 14.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0020 atddr8 r see section 14.3.2.12.1, ?eft justi?d result data (djm=0) and section 14.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0022 atddr9 r see section 14.3.2.12.1, ?eft justi?d result data (djm=0) and section 14.3.2.12.2, ?ight justi?d result data (djm=1) w address name bit 7 6 5 4 3 2 1 bit 0 = unimplemented or reserved figure 14-2. adc12b12c register summary (sheet 2 of 3)
analog-to-digital converter (adc12b12cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 501 0x0024 atddr10 r see section 14.3.2.12.1, ?eft justi?d result data (djm=0) and section 14.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0026 atddr11 r see section 14.3.2.12.1, ?eft justi?d result data (djm=0) and section 14.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0028 - 0x002f unimple- mented r 00000000 w address name bit 7 6 5 4 3 2 1 bit 0 = unimplemented or reserved figure 14-2. adc12b12c register summary (sheet 3 of 3)
analog-to-digital converter (adc12b12cv2) mc9s12g family reference manual, rev.1.23 502 freescale semiconductor 14.3.2 register descriptions this section describes in address order all the adc12b12c registers and their individual bits. 14.3.2.1 atd control register 0 (atdctl0) writes to this register will abort current conversion sequence. read: anytime write: anytime, in special modes always write 0 to reserved bit 7. module base + 0x0000 76543210 r reserved 000 wrap3 wrap2 wrap1 wrap0 w reset 0 0 0 01111 = unimplemented or reserved figure 14-3. atd control register 0 (atdctl0) table 14-1. atdctl0 field descriptions field description 3-0 wrap[3-0] wrap around channel select bits ?these bits determine the channel for wrap around when doing multi-channel conversions. the coding is summarized in table 14-2 . table 14-2. multi-channel wrap around coding wrap3 wrap2 wrap1 wrap0 multiple channel conversions (mult = 1) wraparound to an0 after converting 0000 reserved 1 0001 an1 0010 an2 0011 an3 0100 an4 0101 an5 0110 an6 0111 an7 1000 an8 1001 an9 1010 an10 1011 an11 1100 an11 1101 an11 1110 an11 1111 an11
analog-to-digital converter (adc12b12cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 503 14.3.2.2 atd control register 1 (atdctl1) writes to this register will abort current conversion sequence. read: anytime write: anytime 1 if only an0 should be converted use mult=0. module base + 0x0001 76543210 r etrigsel sres1 sres0 smp_dis etrigch3 etrigch2 etrigch1 etrigch0 w reset 0 0 1 01111 figure 14-4. atd control register 1 (atdctl1) table 14-3. atdctl1 field descriptions field description 7 etrigsel external trigger source select ?this bit selects the external trigger source to be either one of the ad channels or one of the etrig3-0 inputs. see device speci?ation for availability and connectivity of etrig3-0 inputs. if a particular etrig3-0 input option is not available, writing a 1 to etrisel only sets the bit but has no effect, this means that one of the ad channels (selected by etrigch3-0) is con?ured as the source for external trigger. the coding is summarized in table 14-5 . 6? sres[1:0] a/d resolution select ?these bits select the resolution of a/d conversion results. see table 14-4 for coding. 4 smp_dis discharge before sampling bit 0 no discharge before sampling. 1 the internal sample capacitor is discharged before sampling the channel. this adds 2 atd clock cycles to the sampling time. this can help to detect an open circuit instead of measuring the previous sampled channel. 3? etrigch[3:0] external trigger channel select these bits select one of the ad channels or one of the etrig3-0 inputs as source for the external trigger. the coding is summarized in table 14-5 . table 14-4. a/d resolution coding sres1 sres0 a/d resolution 0 0 8-bit data 0 1 10-bit data 1 0 12-bit data 1 1 reserved
analog-to-digital converter (adc12b12cv2) mc9s12g family reference manual, rev.1.23 504 freescale semiconductor 14.3.2.3 atd control register 2 (atdctl2) writes to this register will abort current conversion sequence. read: anytime write: anytime table 14-5. external trigger channel select coding etrigsel etrigch3 etrigch2 etrigch1 etrigch0 external trigger source is 0 0 0 0 0 an0 0 0 0 0 1 an1 0 0 0 1 0 an2 0 0 0 1 1 an3 0 0 1 0 0 an4 0 0 1 0 1 an5 0 0 1 1 0 an6 0 0 1 1 1 an7 0 1 0 0 0 an8 0 1 0 0 1 an9 0 1 0 1 0 an10 0 1 0 1 1 an11 0 1 1 0 0 an11 0 1 1 0 1 an11 0 1 1 1 0 an11 0 1 1 1 1 an11 1 0 0 0 0 etrig0 1 1 only if etrig3-0 input option is available (see device speci?ation), else etrisel is ignored, that means external trigger source is still on one of the ad channels selected by etrigch3-0 1 0 0 0 1 etrig1 1 1 0 0 1 0 etrig2 1 1 0 0 1 1 etrig3 1 1 0 1 x x reserved 1 1 x x x reserved module base + 0x0002 76543210 r0 affc reserved etrigle etrigp etrige ascie acmpie w reset 0 0 0 00000 = unimplemented or reserved figure 14-5. atd control register 2 (atdctl2)
analog-to-digital converter (adc12b12cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 505 table 14-6. atdctl2 field descriptions field description 6 affc atd fast flag clear all 0 atd ?g clearing done by write 1 to respective ccf[ n ] ?g. 1 changes all atd conversion complete ?gs to a fast clear sequence. for compare disabled (cmpe[ n ]=0) a read access to the result register will cause the associated ccf[ n ] ?g to clear automatically. for compare enabled (cmpe[ n ]=1) a write access to the result register will cause the associated ccf[ n ] ?g to clear automatically. 5 reserved do not alter this bit from its reset value.it is for manufacturer use only and can change the atd behavior. 4 etrigle external trigger level/edge control ?this bit controls the sensitivity of the external trigger signal. see table 14-7 for details. 3 etrigp external trigger polarity this bit controls the polarity of the external trigger signal. see table 14-7 for details. 2 etrige external trigger mode enable this bit enables the external trigger on one of the ad channels or one of the etrig3-0 inputs as described in table 14-5 . if the external trigger source is one of the ad channels, the digital input buffer of this channel is enabled. the external trigger allows to synchronize the start of conversion with external events. 0 disable external trigger 1 enable external trigger 1 ascie atd sequence complete interrupt enable 0 atd sequence complete interrupt requests are disabled. 1 atd sequence complete interrupt will be requested whenever scf=1 is set. 0 acmpie atd compare interrupt enable if automatic compare is enabled for conversion n (cmpe[ n ]=1 in atdcmpe register) this bit enables the compare interrupt. if the ccf[ n ] ?g is set (showing a successful compare for conversion n ), the compare interrupt is triggered. 0 atd compare interrupt requests are disabled. 1 for the conversions in a sequence for which automatic compare is enabled (cmpe[ n ]=1), an atd compare interrupt will be requested whenever any of the respective ccf ?gs is set. table 14-7. external trigger con?urations etrigle etrigp external trigger sensitivity 0 0 falling edge 0 1 rising edge 1 0 low level 1 1 high level
analog-to-digital converter (adc12b12cv2) mc9s12g family reference manual, rev.1.23 506 freescale semiconductor 14.3.2.4 atd control register 3 (atdctl3) writes to this register will abort current conversion sequence. read: anytime write: anytime module base + 0x0003 76543210 r djm s8c s4c s2c s1c fifo frz1 frz0 w reset 0 0 1 00000 = unimplemented or reserved figure 14-6. atd control register 3 (atdctl3) table 14-8. atdctl3 field descriptions field description 7 djm result register data justi?ation ?result data format is always unsigned. this bit controls justi?ation of conversion data in the result registers. 0 left justi?d data in the result registers. 1 right justi?d data in the result registers. table 14-9 gives example atd results for an input signal range between 0 and 5.12 volts. 6? s8c, s4c, s2c, s1c conversion sequence length ?these bits control the number of conversions per sequence. table 14-10 shows all combinations. at reset, s4c is set to 1 (sequence length is 4). this is to maintain software continuity to hc12 family. 2 fifo result register fifo mode if this bit is zero (non-fifo mode), the a/d conversion results map into the result registers based on the conversion sequence; the result of the ?st conversion appears in the ?st result register (atddr0), the second result in the second result register (atddr1), and so on. if this bit is one (fifo mode) the conversion counter is not reset at the beginning or end of a conversion sequence; sequential conversion results are placed in consecutive result registers. in a continuously scanning conversion sequence, the result register counter will wrap around when it reaches the end of the result register ?e. the conversion counter value (cc3-0 in atdstat0) can be used to determine where in the result register ?e, the current conversion result will be placed. aborting a conversion or starting a new conversion clears the conversion counter even if fifo=1. so the ?st result of a new conversion sequence, started by writing to atdctl5, will always be place in the ?st result register (atdddr0). intended usage of fifo mode is continuos conversion (scan=1) or triggered conversion (etrig=1). which result registers hold valid data can be tracked using the conversion complete ?gs. fast ?g clear mode may be useful in a particular application to track valid data. if this bit is one, automatic compare of result registers is always disabled, that is adc12b12c will behave as if acmpie and all cpme[ n ] were zero. 0 conversion results are placed in the corresponding result register up to the selected sequence length. 1 conversion results are placed in consecutive result registers (wrap around at end). 1? frz[1:0] background debug freeze enable ?when debugging an application, it is useful in many cases to have the atd pause when a breakpoint (freeze mode) is encountered. these 2 bits determine how the atd will respond to a breakpoint as shown in table 14-11 . leakage onto the storage node and comparator reference capacitors may compromise the accuracy of an immediately frozen conversion depending on the length of the freeze period.
analog-to-digital converter (adc12b12cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 507 table 14-9. examples of ideal decimal atd results input signal vrl = 0 volts vrh = 5.12 volts 8-bit codes (resolution=20mv) 10-bit codes (resolution=5mv) 12-bit codes (transfer curve has 1.25mv offset) (resolution=1.25mv) 5.120 volts ... 0.022 0.020 0.018 0.016 0.014 0.012 0.010 0.008 0.006 0.004 0.003 0.002 0.000 255 ... 1 1 1 1 1 1 1 0 0 0 0 0 0 1023 ... 4 4 4 3 3 2 2 2 1 1 1 0 0 4095 ... 17 16 14 12 11 9 8 6 4 3 2 1 0 table 14-10. conversion sequence length coding s8c s4c s2c s1c number of conversions per sequence 00 0 0 12 00 0 1 1 00 1 0 2 00 1 1 3 01 0 0 4 01 0 1 5 01 1 0 6 01 1 1 7 10 0 0 8 10 0 1 9 10 1 0 10 10 1 1 11 11 0 0 12 11 0 1 12 11 1 0 12 11 1 1 12
analog-to-digital converter (adc12b12cv2) mc9s12g family reference manual, rev.1.23 508 freescale semiconductor 14.3.2.5 atd control register 4 (atdctl4) writes to this register will abort current conversion sequence. read: anytime write: anytime table 14-11. atd behavior in freeze mode (breakpoint) frz1 frz0 behavior in freeze mode 0 0 continue conversion 0 1 reserved 1 0 finish current conversion, then freeze 1 1 freeze immediately module base + 0x0004 76543210 r smp2 smp1 smp0 prs[4:0] w reset 0 0 0 00101 figure 14-7. atd control register 4 (atdctl4) table 14-12. atdctl4 field descriptions field description 7? smp[2:0] sample time select ?these three bits select the length of the sample time in units of atd conversion clock cycles. note that the atd conversion clock period is itself a function of the prescaler value (bits prs4-0). table 14-13 lists the available sample time lengths. 4? prs[4:0] atd clock prescaler these 5 bits are the binary prescaler value prs. the atd conversion clock frequency is calculated as follows: refer to device speci?ation for allowed frequency range of f atdclk . table 14-13. sample time select smp2 smp1 smp0 sample time in number of atd clock cycles 000 4 001 6 010 8 011 10 100 12 101 16 110 20 f atdclk f bus 2 prs 1 + () ------------------------------------- =
analog-to-digital converter (adc12b12cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 509 14.3.2.6 atd control register 5 (atdctl5) writes to this register will abort current conversion sequence and start a new conversion sequence. if the external trigger function is enabled (etrige=1) an initial write to atdctl5 is required to allow starting of a conversion sequence which will then occur on each trigger event. start of conversion means the beginning of the sampling phase. read: anytime write: anytime 111 24 module base + 0x0005 76543210 r0 sc scan mult cd cc cb ca w reset 0 0 0 00000 = unimplemented or reserved figure 14-8. atd control register 5 (atdctl5) table 14-14. atdctl5 field descriptions field description 6 sc special channel conversion bit if this bit is set, then special channel conversion can be selected using cd, cc, cb and ca of atdctl5. table 14-15 lists the coding. 0 special channel conversions disabled 1 special channel conversions enabled 5 scan continuous conversion sequence mode ?this bit selects whether conversion sequences are performed continuously or only once. if the external trigger function is enabled (etrige=1) setting this bit has no effect, thus the external trigger always starts a single conversion sequence. 0 single conversion sequence 1 continuous conversion sequences (scan mode) table 14-13. sample time select smp2 smp1 smp0 sample time in number of atd clock cycles
analog-to-digital converter (adc12b12cv2) mc9s12g family reference manual, rev.1.23 510 freescale semiconductor 4 mult multi-channel sample mode when mult is 0, the atd sequence controller samples only from the speci?d analog input channel for an entire conversion sequence. the analog channel is selected by channel selection code (control bits cd/cc/cb/ca located in atdctl5). when mult is 1, the atd sequence controller samples across channels. the number of channels sampled is determined by the sequence length value (s8c, s4c, s2c, s1c). the ?st analog channel examined is determined by channel selection code (cd, cc, cb, ca control bits); subsequent channels sampled in the sequence are determined by incrementing the channel selection code or wrapping around to an0 (channel 0). 0 sample only one channel 1 sample across several channels 3? cd, cc, cb, ca analog input channel select code ?these bits select the analog input channel(s). table 14-15 lists the coding used to select the various analog input channels. in the case of single channel conversions (mult=0), this selection code speci?s the channel to be examined. in the case of multiple channel conversions (mult=1), this selection code speci?s the ?st channel to be examined in the conversion sequence. subsequent channels are determined by incrementing the channel selection code or wrapping around to an0 (after converting the channel de?ed by the wrap around channel select bits wrap3-0 in atdctl0). when starting with a channel number higher than the one de?ed by wrap3-0 the ?st wrap around will be an11 to an0. table 14-15. analog input channel select coding sc cd cc cb ca analog input channel 00000 an0 0001 an1 0010 an2 0011 an3 0100 an4 0101 an5 0110 an6 0111 an7 1000 an8 1001 an9 1 0 1 0 an10 1 0 1 1 an11 1 1 0 0 an11 1 1 0 1 an11 1 1 1 0 an11 1 1 1 1 an11 table 14-14. atdctl5 field descriptions (continued) field description
analog-to-digital converter (adc12b12cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 511 1 0 0 0 0 internal_6, temperature sense of adc hardmacro 0 0 0 1 internal_7 0 0 1 0 internal_0 0 0 1 1 internal_1 0100 vrh 0101 vrl 0 1 1 0 (vrh+vrl) / 2 0 1 1 1 reserved 1 0 0 0 internal_2 1 0 0 1 internal_3 1 0 1 0 internal_4 1 0 1 1 internal_5 1 1 x x reserved table 14-15. analog input channel select coding sc cd cc cb ca analog input channel
analog-to-digital converter (adc12b12cv2) mc9s12g family reference manual, rev.1.23 512 freescale semiconductor 14.3.2.7 atd status register 0 (atdstat0) this register contains the sequence complete flag, overrun ?gs for external trigger and fifo mode, and the conversion counter. read: anytime write: anytime (no effect on (cc3, cc2, cc1, cc0)) module base + 0x0006 76543210 r scf 0 etorf fifor cc3 cc2 cc1 cc0 w reset 0 0 0 00000 = unimplemented or reserved figure 14-9. atd status register 0 (atdstat0) table 14-16. atdstat0 field descriptions field description 7 scf sequence complete flag ?this ?g is set upon completion of a conversion sequence. if conversion sequences are continuously performed (scan=1), the ?g is set after each one is completed. this ?g is cleared when one of the following occurs: a) write ??to scf b) write to atdctl5 (a new conversion sequence is started) c) if affc=1 and a result register is read 0 conversion sequence not completed 1 conversion sequence has completed 5 etorf external trigger overrun flag ?while in edge sensitive mode (etrigle=0), if additional active edges are detected while a conversion sequence is in process the overrun ?g is set. this ?g is cleared when one of the following occurs: a) write ??to etorf b) write to atdctl0,1,2,3,4, atdcmpe or atdcmpht (a conversion sequence is aborted) c) write to atdctl5 (a new conversion sequence is started) 0 no external trigger overrun error has occurred 1 external trigger overrun error has occurred 4 fifor result register overrun flag this bit indicates that a result register has been written to before its associated conversion complete ?g (ccf) has been cleared. this ?g is most useful when using the fifo mode because the ?g potentially indicates that result registers are out of sync with the input channels. however, it is also practical for non-fifo modes, and indicates that a result register has been overwritten before it has been read (i.e. the old data has been lost). this ?g is cleared when one of the following occurs: a) write ??to fifor b) write to atdctl0,1,2,3,4, atdcmpe or atdcmpht (a conversion sequence is aborted) c) write to atdctl5 (a new conversion sequence is started) 0 no overrun has occurred 1 overrun condition exists (result register has been written while associated ccfx ?g was still set)
analog-to-digital converter (adc12b12cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 513 14.3.2.8 atd compare enable register (atdcmpe) writes to this register will abort current conversion sequence. read: anytime write: anytime 3? cc[3:0] conversion counter these 4 read-only bits are the binary value of the conversion counter. the conversion counter points to the result register that will receive the result of the current conversion. e.g. cc3=0, cc2=1, cc1=1, cc0=0 indicates that the result of the current conversion will be in atd result register 6. if in non-fifo mode (fifo=0) the conversion counter is initialized to zero at the beginning and end of the conversion sequence. if in fifo mode (fifo=1) the register counter is not initialized. the conversion counter wraps around when its maximum value is reached. aborting a conversion or starting a new conversion clears the conversion counter even if fifo=1. module base + 0x0008 15 14 13 11 10 9 8 7 6 5 4 3 2 1 0 r 0 0 0 0 cmpe[11:0] w reset 0 0 0 0 0 0 0 0 0 0000000 = unimplemented or reserved figure 14-10. atd compare enable register (atdcmpe) table 14-17. atdcmpe field descriptions field description 11? cmpe[11:0] compare enable for conversion number n ( n = 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) of a sequence ( n conversion number, not channel number!) these bits enable automatic compare of conversion results individually for conversions of a sequence. the sense of each comparison is determined by the cmpht[ n ] bit in the atdcmpht register. for each conversion number with cmpe[ n ]=1 do the following: 1) write compare value to atddr n result register 2) write compare operator with cmpht[ n ] in atdcpmht register ccf[ n ] in atdstat2 register will ?g individual success of any comparison. 0 no automatic compare 1 automatic compare of results for conversion n of a sequence is enabled. table 14-16. atdstat0 field descriptions (continued) field description
analog-to-digital converter (adc12b12cv2) mc9s12g family reference manual, rev.1.23 514 freescale semiconductor 14.3.2.9 atd status register 2 (atdstat2) this read-only register contains the conversion complete flags ccf[11:0]. read: anytime write: anytime (for details see table 14-18 below) module base + 0x000a 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r 0 0 0 0 ccf[11:0] w reset 0 0 0 0 0 0 0 0 0 0000000 = unimplemented or reserved figure 14-11. atd status register 2 (atdstat2) table 14-18. atdstat2 field descriptions field description 11? ccf[11:0] conversion complete flag n ( n = 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) ( n conversion number, not channel number!) ?a conversion complete ?g is set at the end of each conversion in a sequence. the ?gs are associated with the conversion position in a sequence (and also the result register number). therefore in non-?o mode, ccf[4] is set when the ?th conversion in a sequence is complete and the result is available in result register atddr4; ccf[5] is set when the sixth conversion in a sequence is complete and the result is available in atddr5, and so forth. if automatic compare of conversion results is enabled (cmpe[ n ]=1 in atdcmpe), the conversion complete ?g is only set if comparison with atddr n is true. if acmpie=1 a compare interrupt will be requested. in this case, as the atddr n result register is used to hold the compare value, the result will not be stored there at the end of the conversion but is lost. a ?g ccf[ n ] is cleared when one of the following occurs: a) write to atdctl5 (a new conversion sequence is started) b) if affc=0, write ??to ccf[ n ] c) if affc=1 and cmpe[ n ]=0, read of result register atddr n d) if affc=1 and cmpe[ n ]=1, write to result register atddr n in case of a concurrent set and clear on ccf[ n ]: the clearing by method a) will overwrite the set. the clearing by methods b) or c) or d) will be overwritten by the set. 0 conversion number n not completed or successfully compared 1 if (cmpe[ n ]=0): conversion number n has completed. result is ready in atddr n . if (cmpe[ n ]=1): compare for conversion result number n with compare value in atddr n , using compare operator cmpgt[ n ] is true. (no result available in atddr n )
analog-to-digital converter (adc12b12cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 515 14.3.2.10 atd input enable register (atddien) read: anytime write: anytime 14.3.2.11 atd compare higher than register (atdcmpht) writes to this register will abort current conversion sequence. read: anytime write: anytime module base + 0x000c 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r 1 1 1 1 ien[11:0] w reset 1 1 1 1 0 0 0 0 0 0000000 = unimplemented or reserved figure 14-12. atd input enable register (atddien) table 14-19. atddien field descriptions field description 11? ien[11:0] atd digital input enable on channel x ( x = 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) this bit controls the digital input buffer from the analog input pin (an x ) to the digital data register. 0 disable digital input buffer to an x pin 1 enable digital input buffer on an x pin. note: setting this bit will enable the corresponding digital input buffer continuously. if this bit is set while simultaneously using it as an analog port, there is potentially increased power consumption because the digital input buffer maybe in the linear region. module base + 0x000e 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r 0 0 0 0 cmpht[11:0] w reset 0 0 0 0 0 0 0 0 0 0000000 = unimplemented or reserved figure 14-13. atd compare higher than register (atdcmpht) table 14-20. atdcmpht field descriptions field description 11? cmpht[11:0] compare operation higher than enable for conversion number n ( n = 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) of a sequence ( n conversion number, not channel number!) this bit selects the operator for comparison of conversion results. 0 if result of conversion n is lower or same than compare value in atddr n , this is ?gged in atdstat2 1 if result of conversion n is higher than compare value in atddr n , this is ?gged in atdstat2
analog-to-digital converter (adc12b12cv2) mc9s12g family reference manual, rev.1.23 516 freescale semiconductor 14.3.2.12 atd conversion result registers (atddr n ) the a/d conversion results are stored in 12 result registers. results are always in unsigned data representation. left and right justi?ation is selected using the djm control bit in atdctl3. if automatic compare of conversions results is enabled (cmpe[ n ]=1 in atdcmpe), these registers must be written with the compare values in left or right justi?d format depending on the actual value of the djm bit. in this case, as the atddr n register is used to hold the compare value, the result will not be stored there at the end of the conversion but is lost. attention, n is the conversion number, not the channel number! read: anytime write: anytime note for conversions not using automatic compare, results are stored in the result registers after each conversion. in this case avoid writing to atddrn except for initial values, because an a/d result might be overwritten. 14.3.2.12.1 left justi?d result data (djm=0) table 14-21 shows how depending on the a/d resolution the conversion result is transferred to the atd result registers for left justi?d data. compare is always done using all 12 bits of both the conversion result and the compare value in atddrn. table 14-21. conversion result mapping to atddrn module base + 0x0010 = atddr0, 0x0012 = atddr1, 0x0014 = atddr2, 0x0016 = atddr3 0x0018 = atddr4, 0x001a = atddr5, 0x001c = atddr6, 0x001e = atddr7 0x0020 = atddr8, 0x0022 = atddr9, 0x0024 = atddr10, 0x0026 = atddr11 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r result-bit[11:0] 0 000 w reset 0 0 0 0 0 0 0 0 0 0000000 = unimplemented or reserved figure 14-14. left justi?d atd conversion result register (atddr n ) a/d resolution djm conversion result mapping to atddr n 8-bit data 0 result-bit[11:4] = conversion result, result-bit[3:0]=0000 10-bit data 0 result-bit[11:2] = conversion result, result-bit[1:0]=00 12-bit data 0 result-bit[11:0] = result
analog-to-digital converter (adc12b12cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 517 14.3.2.12.2 right justi?d result data (djm=1) table 14-22 shows how depending on the a/d resolution the conversion result is transferred to the atd result registers for right justi?d data. compare is always done using all 12 bits of both the conversion result and the compare value in atddrn. module base + 0x0010 = atddr0, 0x0012 = atddr1, 0x0014 = atddr2, 0x0016 = atddr3 0x0018 = atddr4, 0x001a = atddr5, 0x001c = atddr6, 0x001e = atddr7 0x0020 = atddr8, 0x0022 = atddr9, 0x0024 = atddr10, 0x0026 = atddr11 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r 0 000 result-bit[11:0] w reset 0 0 0 0 0 0 0 0 0 0000000 = unimplemented or reserved figure 14-15. right justi?d atd conversion result register (atddr n ) table 14-22. conversion result mapping to atddrn a/d resolution djm conversion result mapping to atddr n 8-bit data 1 result-bit[11:8]=0000, result-bit[7:0] = conversion result 10-bit data 1 result-bit[11:10]=00, result-bit[9:0] = conversion result 12-bit data 1 result-bit[11:0] = result
analog-to-digital converter (adc12b12cv2) mc9s12g family reference manual, rev.1.23 518 freescale semiconductor 14.4 functional description the adc12b12c consists of an analog sub-block and a digital sub-block. 14.4.1 analog sub-block the analog sub-block contains all analog electronics required to perform a single conversion. separate power supplies vdda and vssa allow to isolate noise of other mcu circuitry from the analog sub-block. 14.4.1.1 sample and hold machine the sample and hold machine controls the storage and charge of the sample capacitor to the voltage level of the analog signal at the selected adc input channel. during the sample process the analog input connects directly to the storage node. the input analog signals are unipolar and must be within the potential range of vssa to vdda. during the hold process the analog input is disconnected from the storage node. 14.4.1.2 analog input multiplexer the analog input multiplexer connects one of the 12 external analog input channels to the sample and hold machine. 14.4.1.3 analog-to-digital (a/d) machine the a/d machine performs analog to digital conversions. the resolution is program selectable to be either 8 or 10 or 12 bits. the a/d machine uses a successive approximation architecture. it functions by comparing the sampled and stored analog voltage with a series of binary coded discrete voltages. by following a binary search algorithm, the a/d machine identi?s the discrete voltage that is nearest to the sampled and stored voltage. when not converting the a/d machine is automatically powered down. only analog input signals within the potential range of vrl to vrh (a/d reference potentials) will result in a non-railed digital output code. 14.4.2 digital sub-block this subsection describes some of the digital features in more detail. see section 14.3.2, ?egister descriptions for all details. 14.4.2.1 external trigger input the external trigger feature allows the user to synchronize atd conversions to an external event rather than relying only on software to trigger the atd module when a conversions is about to take place. the external trigger signal (out of reset atd channel 11, con?urable in atdctl1) is programmable to be
analog-to-digital converter (adc12b12cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 519 edge or level sensitive with polarity control. table 14-23 gives a brief description of the different combinations of control bits and their effect on the external trigger function. in order to avoid maybe false trigger events please enable the external digital input via atddien register ?st and in the following enable the external trigger mode by bit etrige. in either level or edge sensitive modes, the ?st conversion begins when the trigger is received. once etrige is enabled a conversion must be triggered externally after writing to atdctl5 register. during a conversion in edge sensitive mode, if additional trigger events are detected the overrun error ?g etorf is set. if level sensitive mode is active and the external trigger de-asserts and later asserts again during a conversion sequence, this does not constitute an overrun. therefore, the ?g is not set. if the trigger is left active in level sensitive mode when a sequence is about to complete, another sequence will be triggered immediately. 14.4.2.2 general-purpose digital port operation each atd input pin can be switched between analog or digital input functionality. an analog multiplexer makes each atd input pin selected as analog input available to the a/d converter. the pad of the atd input pin is always connected to the analog input channel of the analog mulitplexer. each pad input signal is buffered to the digital port register. this buffer can be turned on or off with the atddien register for each atd input pin. this is important so that the buffer does not draw excess current when an atd input pin is selected as analog input to the adc12b12c. table 14-23. external trigger control bits etrigle etrigp etrige scan description x x 0 0 ignores external trigger. performs one conversion sequence and stops. x x 0 1 ignores external trigger. performs continuous conversion sequences. 0 0 1 x trigger falling edge sensitive. performs one conversion sequence per trigger. 0 1 1 x trigger rising edge sensitive. performs one conversion sequence per trigger. 1 0 1 x trigger low level sensitive. performs continuous conversions while trigger level is active. 1 1 1 x trigger high level sensitive. performs continuous conversions while trigger level is active.
analog-to-digital converter (adc12b12cv2) mc9s12g family reference manual, rev.1.23 520 freescale semiconductor 14.5 resets at reset the adc12b12c is in a power down state. the reset state of each individual bit is listed within the register description section (see section 14.3.2, ?egister descriptions ) which details the registers and their bit-?ld. 14.6 interrupts the interrupts requested by the adc12b12c are listed in table 14-24 . refer to mcu speci?ation for related vector address and priority. see section 14.3.2, ?egister descriptions for further details. table 14-24. atd interrupt vectors interrupt source ccr mask local enable sequence complete interrupt i bit ascie in atdctl2 compare interrupt i bit acmpie in atdctl2
mc9s12g family reference manual, rev.1.23 freescale semiconductor 521 chapter 15 analog-to-digital converter (adc10b16cv2) revision history version number revision date effective date author description of changes v02.00 18 june 2009 18 june 2009 initial version copied 12 channel block guide v02.01 09 feb 2010 09 feb 2010 updated table 15-15 analog input channel select coding - description of internal channels. updated register atddr (left/right justi?d result) description in section 15.3.2.12.1/15-541 and 15.3.2.12.2/15-542 and added table 15-21 to improve feature description. fixed typo in table 15-9 - conversion result for 3mv and 10bit resolution v02.03 26 feb 2010 26 feb 2010 corrected table 15-15 analog input channel select coding - description of internal channels. v02.04 26 mar 2010 16 mar 2010 corrected typo: reset value of atddien register v02.05 14 apr 2010 14 apr 2010 corrected typos to be in-line with soc level pin naming conventions for vdda, vssa, vrl and vrh. v02.06 25 aug 2010 25 aug 2010 removed feature of conversion during stop and general wording clean up done in section 15.4, ?unctional description v02.07 09 sep 2010 09 sep 2010 update of internal only information. v02.08 11 feb 2011 11 feb 2011 connectivity information regarding internal channel_6 added to table 15-15 . v02.09 29 mar 2011 29 mar 2011 fixed typo in bit description ?ld table 15-14 for bits cd, cc, cb, ca. last sentence contained a wrong highest channel number (it is not an7 to an0 instead it is an15 to an0). v02.10 22. jun 2012 22. jun 2012 updated register wirte access information in section 15.3.2.9/15-539 v02.11 29. jun 2012 29. jun 2012 removed ip name in block diagram figure 15-1 v02.12 02 oct 2012 02 oct 2012 added user information to avoid maybe false external trigger events when enabling the external trigger mode ( section 15.4.2.1, ?xternal trigger input ).
analog-to-digital converter (adc10b16cv2) mc9s12g family reference manual, rev.1.23 522 freescale semiconductor 15.1 introduction the adc10b16c is a 16-channel, 10-bit, multiplexed input successive approximation analog-to-digital converter. refer to device electrical speci?ations for atd accuracy. 15.1.1 features 8-, 10-bit resolution. automatic return to low power after conversion sequence automatic compare with interrupt for higher than or less/equal than programmable value programmable sample time. left/right justi?d result data. external trigger control. sequence complete interrupt. analog input multiplexer for 8 analog input channels. special conversions for vrh, vrl, (vrl+vrh)/2 and adc temperature sensor. 1-to-16 conversion sequence lengths. continuous conversion mode. multiple channel scans. con?urable external trigger functionality on any ad channel or any of four additional trigger inputs. the four additional trigger inputs can be chip external or internal. refer to device speci?ation for availability and connectivity. con?urable location for channel wrap around (when converting multiple channels in a sequence).
analog-to-digital converter (adc10b16cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 523 15.1.2 modes of operation 15.1.2.1 conversion modes there is software programmable selection between performing single or continuous conversion on a single channel or multiple channels . 15.1.2.2 mcu operating modes stop mode entering stop mode aborts any conversion sequence in progress and if a sequence was aborted restarts it after exiting stop mode. this has the same effect/consequences as starting a conversion sequence with write to atdctl5. so after exiting from stop mode with a previously aborted sequence all ?gs are cleared etc. wait mode adc10b16c behaves same in run and wait mode. for reduced power consumption continuous conversions should be aborted before entering wait mode. freeze mode in freeze mode the adc10b16c will either continue or ?ish or stop converting according to the frz1 and frz0 bits. this is useful for debugging and emulation.
analog-to-digital converter (adc10b16cv2) mc9s12g family reference manual, rev.1.23 524 freescale semiconductor 15.1.3 block diagram figure 15-1. adc10b16c block diagram vssa an9 analog mux mode and successive approximation register (sar) results atd 0 atd 1 atd 2 atd 3 atd 4 atd 5 atd 6 atd 7 and dac sample & hold vdda vrl vrh sequence complete + - comparator clock prescaler bus clock atd clock an7 an6 an5 an10 etrig0 (see device speci? cation for availability etrig1 etrig2 etrig3 and connectivity) timing control atddien atdctl1 trigger mux interrupt compare interrupt an4 an11 an12 an13 an14 atd 8 atd 9 atd 10 atd 11 atd 13 atd 14 atd 12 atd 15 an3 an2 an1 an0 an8 an15
analog-to-digital converter (adc10b16cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 525 15.2 signal description this section lists all inputs to the adc10b16c block. 15.2.1 detailed signal descriptions 15.2.1.1 an x ( x = 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) this pin serves as the analog input channel x . it can also be con?ured as digital port or external trigger for the atd conversion. 15.2.1.2 etrig3, etrig2, etrig1, etrig0 these inputs can be con?ured to serve as an external trigger for the atd conversion. refer to device speci?ation for availability and connectivity of these inputs! 15.2.1.3 vrh, vrl vrh is the high reference voltage, vrl is the low reference voltage for atd conversion. 15.2.1.4 vdda, vssa these pins are the power supplies for the analog circuitry of the adc10b16c block. 15.3 memory map and register de?ition this section provides a detailed description of all registers accessible in the adc10b16c. 15.3.1 module memory map figure 15-2 gives an overview on all adc10b16c registers. note register address = base address + address offset, where the base address is de?ed at the mcu level and the address offset is de?ed at the module level. address name bit 7 6 5 4 3 2 1 bit 0 0x0000 atdctl0 r reserved 000 wrap3 wrap2 wrap1 wrap0 w 0x0001 atdctl1 r etrigsel sres1 sres0 smp_dis etrigch3 etrigch2 etrigch1 etrigch0 w 0x0002 atdctl2 r0 affc reserved etrigle etrigp etrige ascie acmpie w = unimplemented or reserved figure 15-2. adc10b16c register summary (sheet 1 of 3)
analog-to-digital converter (adc10b16cv2) mc9s12g family reference manual, rev.1.23 526 freescale semiconductor 0x0003 atdctl3 r djm s8c s4c s2c s1c fifo frz1 frz0 w 0x0004 atdctl4 r smp2 smp1 smp0 prs[4:0] w 0x0005 atdctl5 r0 sc scan mult cd cc cb ca w 0x0006 atdstat0 r scf 0 etorf fifor cc3 cc2 cc1 cc0 w 0x0007 unimple- mented r0 000 0 0 0 0 w 0x0008 atdcmpeh r cmpe[15:8] w 0x0009 atdcmpel r cmpe[7:0] w 0x000a atdstat2h r ccf[15:8] w 0x000b atdstat2l r ccf[7:0] w 0x000c atddienh r ien[15:8] w 0x000d atddienl r ien[7:0] w 0x000e atdcmphth r cmpht[15:8] w 0x000f atdcmphtl r cmpht[7:0] w 0x0010 atddr0 r see section 15.3.2.12.1, ?eft justi?d result data (djm=0) and section 15.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0012 atddr1 r see section 15.3.2.12.1, ?eft justi?d result data (djm=0) and section 15.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0014 atddr2 r see section 15.3.2.12.1, ?eft justi?d result data (djm=0) and section 15.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0016 atddr3 r see section 15.3.2.12.1, ?eft justi?d result data (djm=0) and section 15.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0018 atddr4 r see section 15.3.2.12.1, ?eft justi?d result data (djm=0) and section 15.3.2.12.2, ?ight justi?d result data (djm=1) w 0x001a atddr5 r see section 15.3.2.12.1, ?eft justi?d result data (djm=0) and section 15.3.2.12.2, ?ight justi?d result data (djm=1) w 0x001c atddr6 r see section 15.3.2.12.1, ?eft justi?d result data (djm=0) and section 15.3.2.12.2, ?ight justi?d result data (djm=1) w 0x001e atddr7 r see section 15.3.2.12.1, ?eft justi?d result data (djm=0) and section 15.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0020 atddr8 r see section 15.3.2.12.1, ?eft justi?d result data (djm=0) and section 15.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0022 atddr9 r see section 15.3.2.12.1, ?eft justi?d result data (djm=0) and section 15.3.2.12.2, ?ight justi?d result data (djm=1) w address name bit 7 6 5 4 3 2 1 bit 0 = unimplemented or reserved figure 15-2. adc10b16c register summary (sheet 2 of 3)
analog-to-digital converter (adc10b16cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 527 0x0024 atddr10 r see section 15.3.2.12.1, ?eft justi?d result data (djm=0) and section 15.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0026 atddr11 r see section 15.3.2.12.1, ?eft justi?d result data (djm=0) and section 15.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0028 atddr12 r see section 15.3.2.12.1, ?eft justi?d result data (djm=0) and section 15.3.2.12.2, ?ight justi?d result data (djm=1) w 0x002a atddr13 r see section 15.3.2.12.1, ?eft justi?d result data (djm=0) and section 15.3.2.12.2, ?ight justi?d result data (djm=1) w 0x002c atddr14 r see section 15.3.2.12.1, ?eft justi?d result data (djm=0) and section 15.3.2.12.2, ?ight justi?d result data (djm=1) w 0x002e atddr15 r see section 15.3.2.12.1, ?eft justi?d result data (djm=0) and section 15.3.2.12.2, ?ight justi?d result data (djm=1) w w address name bit 7 6 5 4 3 2 1 bit 0 = unimplemented or reserved figure 15-2. adc10b16c register summary (sheet 3 of 3)
analog-to-digital converter (adc10b16cv2) mc9s12g family reference manual, rev.1.23 528 freescale semiconductor 15.3.2 register descriptions this section describes in address order all the adc10b16c registers and their individual bits. 15.3.2.1 atd control register 0 (atdctl0) writes to this register will abort current conversion sequence. read: anytime write: anytime, in special modes always write 0 to reserved bit 7. module base + 0x0000 76543210 r reserved 000 wrap3 wrap2 wrap1 wrap0 w reset 0 0 0 01111 = unimplemented or reserved figure 15-3. atd control register 0 (atdctl0) table 15-1. atdctl0 field descriptions field description 3-0 wrap[3-0] wrap around channel select bits ?these bits determine the channel for wrap around when doing multi-channel conversions. the coding is summarized in table 15-2 . table 15-2. multi-channel wrap around coding wrap3 wrap2 wrap1 wrap0 multiple channel conversions (mult = 1) wraparound to an0 after converting 0000 reserved 1 0001 an1 0010 an2 0011 an3 0100 an4 0101 an5 0110 an6 0111 an7 1000 an8 1001 an9 1010 an10 1011 an11 1100 an12 1101 an13 1110 an14 1111 an15
analog-to-digital converter (adc10b16cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 529 15.3.2.2 atd control register 1 (atdctl1) writes to this register will abort current conversion sequence. read: anytime write: anytime 1 if only an0 should be converted use mult=0. module base + 0x0001 76543210 r etrigsel sres1 sres0 smp_dis etrigch3 etrigch2 etrigch1 etrigch0 w reset 0 0 1 01111 figure 15-4. atd control register 1 (atdctl1) table 15-3. atdctl1 field descriptions field description 7 etrigsel external trigger source select ?this bit selects the external trigger source to be either one of the ad channels or one of the etrig3-0 inputs. see device speci?ation for availability and connectivity of etrig3-0 inputs. if a particular etrig3-0 input option is not available, writing a 1 to etrisel only sets the bit but has no effect, this means that one of the ad channels (selected by etrigch3-0) is con?ured as the source for external trigger. the coding is summarized in table 15-5 . 6? sres[1:0] a/d resolution select ?these bits select the resolution of a/d conversion results. see table 15-4 for coding. 4 smp_dis discharge before sampling bit 0 no discharge before sampling. 1 the internal sample capacitor is discharged before sampling the channel. this adds 2 atd clock cycles to the sampling time. this can help to detect an open circuit instead of measuring the previous sampled channel. 3? etrigch[3:0] external trigger channel select these bits select one of the ad channels or one of the etrig3-0 inputs as source for the external trigger. the coding is summarized in table 15-5 . table 15-4. a/d resolution coding sres1 sres0 a/d resolution 0 0 8-bit data 0 1 10-bit data 1 0 reserved 1 1 reserved
analog-to-digital converter (adc10b16cv2) mc9s12g family reference manual, rev.1.23 530 freescale semiconductor 15.3.2.3 atd control register 2 (atdctl2) writes to this register will abort current conversion sequence. read: anytime write: anytime table 15-5. external trigger channel select coding etrigsel etrigch3 etrigch2 etrigch1 etrigch0 external trigger source is 0 0 0 0 0 an0 0 0 0 0 1 an1 0 0 0 1 0 an2 0 0 0 1 1 an3 0 0 1 0 0 an4 0 0 1 0 1 an5 0 0 1 1 0 an6 0 0 1 1 1 an7 0 1 0 0 0 an8 0 1 0 0 1 an9 0 1 0 1 0 an10 0 1 0 1 1 an11 0 1 1 0 0 an12 0 1 1 0 1 an13 0 1 1 1 0 an14 0 1 1 1 1 an15 1 0 0 0 0 etrig0 1 1 only if etrig3-0 input option is available (see device speci?ation), else etrisel is ignored, that means external trigger source is still on one of the ad channels selected by etrigch3-0 1 0 0 0 1 etrig1 1 1 0 0 1 0 etrig2 1 1 0 0 1 1 etrig3 1 1 0 1 x x reserved 1 1 x x x reserved module base + 0x0002 76543210 r0 affc reserved etrigle etrigp etrige ascie acmpie w reset 0 0 0 00000 = unimplemented or reserved figure 15-5. atd control register 2 (atdctl2)
analog-to-digital converter (adc10b16cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 531 table 15-6. atdctl2 field descriptions field description 6 affc atd fast flag clear all 0 atd ?g clearing done by write 1 to respective ccf[ n ] ?g. 1 changes all atd conversion complete ?gs to a fast clear sequence. for compare disabled (cmpe[ n ]=0) a read access to the result register will cause the associated ccf[ n ] ?g to clear automatically. for compare enabled (cmpe[ n ]=1) a write access to the result register will cause the associated ccf[ n ] ?g to clear automatically. 5 reserved do not alter this bit from its reset value.it is for manufacturer use only and can change the atd behavior. 4 etrigle external trigger level/edge control ?this bit controls the sensitivity of the external trigger signal. see table 15-7 for details. 3 etrigp external trigger polarity this bit controls the polarity of the external trigger signal. see table 15-7 for details. 2 etrige external trigger mode enable this bit enables the external trigger on one of the ad channels or one of the etrig3-0 inputs as described in table 15-5 . if the external trigger source is one of the ad channels, the digital input buffer of this channel is enabled. the external trigger allows to synchronize the start of conversion with external events. 0 disable external trigger 1 enable external trigger 1 ascie atd sequence complete interrupt enable 0 atd sequence complete interrupt requests are disabled. 1 atd sequence complete interrupt will be requested whenever scf=1 is set. 0 acmpie atd compare interrupt enable if automatic compare is enabled for conversion n (cmpe[ n ]=1 in atdcmpe register) this bit enables the compare interrupt. if the ccf[ n ] ?g is set (showing a successful compare for conversion n ), the compare interrupt is triggered. 0 atd compare interrupt requests are disabled. 1 for the conversions in a sequence for which automatic compare is enabled (cmpe[ n ]=1), an atd compare interrupt will be requested whenever any of the respective ccf ?gs is set. table 15-7. external trigger con?urations etrigle etrigp external trigger sensitivity 0 0 falling edge 0 1 rising edge 1 0 low level 1 1 high level
analog-to-digital converter (adc10b16cv2) mc9s12g family reference manual, rev.1.23 532 freescale semiconductor 15.3.2.4 atd control register 3 (atdctl3) writes to this register will abort current conversion sequence. read: anytime write: anytime module base + 0x0003 76543210 r djm s8c s4c s2c s1c fifo frz1 frz0 w reset 0 0 1 00000 = unimplemented or reserved figure 15-6. atd control register 3 (atdctl3) table 15-8. atdctl3 field descriptions field description 7 djm result register data justi?ation ?result data format is always unsigned. this bit controls justi?ation of conversion data in the result registers. 0 left justi?d data in the result registers. 1 right justi?d data in the result registers. table 15-9 gives example atd results for an input signal range between 0 and 5.12 volts. 6? s8c, s4c, s2c, s1c conversion sequence length ?these bits control the number of conversions per sequence. table 15-10 shows all combinations. at reset, s4c is set to 1 (sequence length is 4). this is to maintain software continuity to hc12 family. 2 fifo result register fifo mode if this bit is zero (non-fifo mode), the a/d conversion results map into the result registers based on the conversion sequence; the result of the ?st conversion appears in the ?st result register (atddr0), the second result in the second result register (atddr1), and so on. if this bit is one (fifo mode) the conversion counter is not reset at the beginning or end of a conversion sequence; sequential conversion results are placed in consecutive result registers. in a continuously scanning conversion sequence, the result register counter will wrap around when it reaches the end of the result register ?e. the conversion counter value (cc3-0 in atdstat0) can be used to determine where in the result register ?e, the current conversion result will be placed. aborting a conversion or starting a new conversion clears the conversion counter even if fifo=1. so the ?st result of a new conversion sequence, started by writing to atdctl5, will always be place in the ?st result register (atdddr0). intended usage of fifo mode is continuos conversion (scan=1) or triggered conversion (etrig=1). which result registers hold valid data can be tracked using the conversion complete ?gs. fast ?g clear mode may be useful in a particular application to track valid data. if this bit is one, automatic compare of result registers is always disabled, that is adc10b16c will behave as if acmpie and all cpme[ n ] were zero. 0 conversion results are placed in the corresponding result register up to the selected sequence length. 1 conversion results are placed in consecutive result registers (wrap around at end). 1? frz[1:0] background debug freeze enable ?when debugging an application, it is useful in many cases to have the atd pause when a breakpoint (freeze mode) is encountered. these 2 bits determine how the atd will respond to a breakpoint as shown in table 15-11 . leakage onto the storage node and comparator reference capacitors may compromise the accuracy of an immediately frozen conversion depending on the length of the freeze period.
analog-to-digital converter (adc10b16cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 533 table 15-9. examples of ideal decimal atd results input signal vrl = 0 volts vrh = 5.12 volts 8-bit codes (resolution=20mv) 10-bit codes (resolution=5mv) reserved 5.120 volts ... 0.022 0.020 0.018 0.016 0.014 0.012 0.010 0.008 0.006 0.004 0.003 0.002 0.000 255 ... 1 1 1 1 1 1 1 0 0 0 0 0 0 1023 ... 4 4 4 3 3 2 2 2 1 1 1 0 0 reserved table 15-10. conversion sequence length coding s8c s4c s2c s1c number of conversions per sequence 00 0 0 16 00 0 1 1 00 1 0 2 00 1 1 3 01 0 0 4 01 0 1 5 01 1 0 6 01 1 1 7 10 0 0 8 10 0 1 9 10 1 0 10 10 1 1 11 11 0 0 12 11 0 1 13 11 1 0 14 11 1 1 15 table 15-11. atd behavior in freeze mode (breakpoint) frz1 frz0 behavior in freeze mode 0 0 continue conversion
analog-to-digital converter (adc10b16cv2) mc9s12g family reference manual, rev.1.23 534 freescale semiconductor 15.3.2.5 atd control register 4 (atdctl4) writes to this register will abort current conversion sequence. read: anytime write: anytime 0 1 reserved 1 0 finish current conversion, then freeze 1 1 freeze immediately module base + 0x0004 76543210 r smp2 smp1 smp0 prs[4:0] w reset 0 0 0 00101 figure 15-7. atd control register 4 (atdctl4) table 15-12. atdctl4 field descriptions field description 7? smp[2:0] sample time select ?these three bits select the length of the sample time in units of atd conversion clock cycles. note that the atd conversion clock period is itself a function of the prescaler value (bits prs4-0). table 15-13 lists the available sample time lengths. 4? prs[4:0] atd clock prescaler these 5 bits are the binary prescaler value prs. the atd conversion clock frequency is calculated as follows: refer to device speci?ation for allowed frequency range of f atdclk . table 15-13. sample time select smp2 smp1 smp0 sample time in number of atd clock cycles 000 4 001 6 010 8 011 10 100 12 101 16 110 20 111 24 table 15-11. atd behavior in freeze mode (breakpoint) frz1 frz0 behavior in freeze mode f atdclk f bus 2 prs 1 + () ------------------------------------- =
analog-to-digital converter (adc10b16cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 535 15.3.2.6 atd control register 5 (atdctl5) writes to this register will abort current conversion sequence and start a new conversion sequence. if the external trigger function is enabled (etrige=1) an initial write to atdctl5 is required to allow starting of a conversion sequence which will then occur on each trigger event. start of conversion means the beginning of the sampling phase. read: anytime write: anytime module base + 0x0005 76543210 r0 sc scan mult cd cc cb ca w reset 0 0 0 00000 = unimplemented or reserved figure 15-8. atd control register 5 (atdctl5) table 15-14. atdctl5 field descriptions field description 6 sc special channel conversion bit if this bit is set, then special channel conversion can be selected using cd, cc, cb and ca of atdctl5. table 15-15 lists the coding. 0 special channel conversions disabled 1 special channel conversions enabled 5 scan continuous conversion sequence mode ?this bit selects whether conversion sequences are performed continuously or only once. if the external trigger function is enabled (etrige=1) setting this bit has no effect, thus the external trigger always starts a single conversion sequence. 0 single conversion sequence 1 continuous conversion sequences (scan mode) 4 mult multi-channel sample mode when mult is 0, the atd sequence controller samples only from the speci?d analog input channel for an entire conversion sequence. the analog channel is selected by channel selection code (control bits cd/cc/cb/ca located in atdctl5). when mult is 1, the atd sequence controller samples across channels. the number of channels sampled is determined by the sequence length value (s8c, s4c, s2c, s1c). the ?st analog channel examined is determined by channel selection code (cd, cc, cb, ca control bits); subsequent channels sampled in the sequence are determined by incrementing the channel selection code or wrapping around to an0 (channel 0). 0 sample only one channel 1 sample across several channels 3? cd, cc, cb, ca analog input channel select code ?these bits select the analog input channel(s). table 15-15 lists the coding used to select the various analog input channels. in the case of single channel conversions (mult=0), this selection code speci?s the channel to be examined. in the case of multiple channel conversions (mult=1), this selection code speci?s the ?st channel to be examined in the conversion sequence. subsequent channels are determined by incrementing the channel selection code or wrapping around to an0 (after converting the channel de?ed by the wrap around channel select bits wrap3-0 in atdctl0). when starting with a channel number higher than the one de?ed by wrap3-0 the ?st wrap around will be an16 to an0.
analog-to-digital converter (adc10b16cv2) mc9s12g family reference manual, rev.1.23 536 freescale semiconductor table 15-15. analog input channel select coding sc cd cc cb ca analog input channel 00000 an0 0001 an1 0010 an2 0011 an3 0100 an4 0101 an5 0110 an6 0111 an7 1000 an8 1001 an9 1 0 1 0 an10 1 0 1 1 an11 1 1 0 0 an12 1 1 0 1 an13 1 1 1 0 an14 1 1 1 1 an15 1 0 0 0 0 internal_6, temperature sense of adc hardmacro 0 0 0 1 internal_7 0 0 1 0 internal_0 0 0 1 1 internal_1 0100 vrh 0101 vrl 0 1 1 0 (vrh+vrl) / 2 0 1 1 1 reserved 1 0 0 0 internal_2 1 0 0 1 internal_3 1 0 1 0 internal_4 1 0 1 1 internal_5 1 1 x x reserved
analog-to-digital converter (adc10b16cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 537 15.3.2.7 atd status register 0 (atdstat0) this register contains the sequence complete flag, overrun ?gs for external trigger and fifo mode, and the conversion counter. read: anytime write: anytime (no effect on (cc3, cc2, cc1, cc0)) module base + 0x0006 76543210 r scf 0 etorf fifor cc3 cc2 cc1 cc0 w reset 0 0 0 00000 = unimplemented or reserved figure 15-9. atd status register 0 (atdstat0) table 15-16. atdstat0 field descriptions field description 7 scf sequence complete flag ?this ?g is set upon completion of a conversion sequence. if conversion sequences are continuously performed (scan=1), the ?g is set after each one is completed. this ?g is cleared when one of the following occurs: a) write ??to scf b) write to atdctl5 (a new conversion sequence is started) c) if affc=1 and a result register is read 0 conversion sequence not completed 1 conversion sequence has completed 5 etorf external trigger overrun flag ?while in edge sensitive mode (etrigle=0), if additional active edges are detected while a conversion sequence is in process the overrun ?g is set. this ?g is cleared when one of the following occurs: a) write ??to etorf b) write to atdctl0,1,2,3,4, atdcmpe or atdcmpht (a conversion sequence is aborted) c) write to atdctl5 (a new conversion sequence is started) 0 no external trigger overrun error has occurred 1 external trigger overrun error has occurred 4 fifor result register overrun flag this bit indicates that a result register has been written to before its associated conversion complete ?g (ccf) has been cleared. this ?g is most useful when using the fifo mode because the ?g potentially indicates that result registers are out of sync with the input channels. however, it is also practical for non-fifo modes, and indicates that a result register has been overwritten before it has been read (i.e. the old data has been lost). this ?g is cleared when one of the following occurs: a) write ??to fifor b) write to atdctl0,1,2,3,4, atdcmpe or atdcmpht (a conversion sequence is aborted) c) write to atdctl5 (a new conversion sequence is started) 0 no overrun has occurred 1 overrun condition exists (result register has been written while associated ccfx ?g was still set)
analog-to-digital converter (adc10b16cv2) mc9s12g family reference manual, rev.1.23 538 freescale semiconductor 15.3.2.8 atd compare enable register (atdcmpe) writes to this register will abort current conversion sequence. read: anytime write: anytime 3? cc[3:0] conversion counter these 4 read-only bits are the binary value of the conversion counter. the conversion counter points to the result register that will receive the result of the current conversion. e.g. cc3=0, cc2=1, cc1=1, cc0=0 indicates that the result of the current conversion will be in atd result register 6. if in non-fifo mode (fifo=0) the conversion counter is initialized to zero at the beginning and end of the conversion sequence. if in fifo mode (fifo=1) the register counter is not initialized. the conversion counter wraps around when its maximum value is reached. aborting a conversion or starting a new conversion clears the conversion counter even if fifo=1. module base + 0x0008 15 14 13 11 10 9 8 7 6 5 4 3 2 1 0 r cmpe[15:0] w reset 0 0 0 0 0 0 0 0 0 0000000 = unimplemented or reserved figure 15-10. atd compare enable register (atdcmpe) table 15-17. atdcmpe field descriptions field description 15? cmpe[15:0] compare enable for conversion number n ( n = 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) of a sequence ( n conversion number, not channel number!) these bits enable automatic compare of conversion results individually for conversions of a sequence. the sense of each comparison is determined by the cmpht[ n ] bit in the atdcmpht register. for each conversion number with cmpe[ n ]=1 do the following: 1) write compare value to atddr n result register 2) write compare operator with cmpht[ n ] in atdcpmht register ccf[ n ] in atdstat2 register will ?g individual success of any comparison. 0 no automatic compare 1 automatic compare of results for conversion n of a sequence is enabled. table 15-16. atdstat0 field descriptions (continued) field description
analog-to-digital converter (adc10b16cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 539 15.3.2.9 atd status register 2 (atdstat2) this read-only register contains the conversion complete flags ccf[15:0]. read: anytime write: anytime (for details see table 15-18 below) module base + 0x000a 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r ccf[15:0] w reset 0 0 0 0 0 0 0 0 0 0000000 = unimplemented or reserved figure 15-11. atd status register 2 (atdstat2) table 15-18. atdstat2 field descriptions field description 15? ccf[15:0] conversion complete flag n ( n = 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) ( n conversion number, not channel number!) a conversion complete ?g is set at the end of each conversion in a sequence. the ?gs are associated with the conversion position in a sequence (and also the result register number). therefore in non-?o mode, ccf[4] is set when the ?th conversion in a sequence is complete and the result is available in result register atddr4; ccf[5] is set when the sixth conversion in a sequence is complete and the result is available in atddr5, and so forth. if automatic compare of conversion results is enabled (cmpe[ n ]=1 in atdcmpe), the conversion complete ?g is only set if comparison with atddr n is true. if acmpie=1 a compare interrupt will be requested. in this case, as the atddr n result register is used to hold the compare value, the result will not be stored there at the end of the conversion but is lost. a ?g ccf[ n ] is cleared when one of the following occurs: a) write to atdctl5 (a new conversion sequence is started) b) if affc=0, write ??to ccf[ n ] c) if affc=1 and cmpe[ n ]=0, read of result register atddr n d) if affc=1 and cmpe[ n ]=1, write to result register atddr n in case of a concurrent set and clear on ccf[ n ]: the clearing by method a) will overwrite the set. the clearing by methods b) or c) or d) will be overwritten by the set. 0 conversion number n not completed or successfully compared 1 if (cmpe[ n ]=0): conversion number n has completed. result is ready in atddr n . if (cmpe[ n ]=1): compare for conversion result number n with compare value in atddr n , using compare operator cmpgt[ n ] is true. (no result available in atddr n )
analog-to-digital converter (adc10b16cv2) mc9s12g family reference manual, rev.1.23 540 freescale semiconductor 15.3.2.10 atd input enable register (atddien) read: anytime write: anytime 15.3.2.11 atd compare higher than register (atdcmpht) writes to this register will abort current conversion sequence. read: anytime write: anytime module base + 0x000c 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r ien[15:0] w reset 0 0 0 0 0 0 0 0 0 0000000 = unimplemented or reserved figure 15-12. atd input enable register (atddien) table 15-19. atddien field descriptions field description 15? ien[15:0] atd digital input enable on channel x ( x = 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) this bit controls the digital input buffer from the analog input pin (an x ) to the digital data register. 0 disable digital input buffer to an x pin 1 enable digital input buffer on an x pin. note: setting this bit will enable the corresponding digital input buffer continuously. if this bit is set while simultaneously using it as an analog port, there is potentially increased power consumption because the digital input buffer maybe in the linear region. module base + 0x000e 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r cmpht[15:0] w reset 0 0 0 0 0 0 0 0 0 0000000 = unimplemented or reserved figure 15-13. atd compare higher than register (atdcmpht) table 15-20. atdcmpht field descriptions field description 15? cmpht[15:0] compare operation higher than enable for conversion number n ( n = 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) of a sequence ( n conversion number, not channel number!) this bit selects the operator for comparison of conversion results. 0 if result of conversion n is lower or same than compare value in atddr n , this is ?gged in atdstat2 1 if result of conversion n is higher than compare value in atddr n , this is ?gged in atdstat2
analog-to-digital converter (adc10b16cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 541 15.3.2.12 atd conversion result registers (atddr n ) the a/d conversion results are stored in 16 result registers. results are always in unsigned data representation. left and right justi?ation is selected using the djm control bit in atdctl3. if automatic compare of conversions results is enabled (cmpe[ n ]=1 in atdcmpe), these registers must be written with the compare values in left or right justi?d format depending on the actual value of the djm bit. in this case, as the atddr n register is used to hold the compare value, the result will not be stored there at the end of the conversion but is lost. attention, n is the conversion number, not the channel number! read: anytime write: anytime note for conversions not using automatic compare, results are stored in the result registers after each conversion. in this case avoid writing to atddrn except for initial values, because an a/d result might be overwritten. 15.3.2.12.1 left justi?d result data (djm=0) table 15-21 shows how depending on the a/d resolution the conversion result is transferred to the atd result registers for left justi?d data. compare is always done using all 12 bits of both the conversion result and the compare value in atddrn. module base + 0x0010 = atddr0, 0x0012 = atddr1, 0x0014 = atddr2, 0x0016 = atddr3 0x0018 = atddr4, 0x001a = atddr5, 0x001c = atddr6, 0x001e = atddr7 0x0020 = atddr8, 0x0022 = atddr9, 0x0024 = atddr10, 0x0026 = atddr11 0x0028 = atddr12, 0x002a = atddr13, 0x002c = atddr14, 0x002e = atddr15 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r result-bit[11:0] 0 000 w reset 0 0 0 0 0 0 0 0 0 0000000 = unimplemented or reserved figure 15-14. left justi?d atd conversion result register (atddr n ) table 15-21. conversion result mapping to atddrn a/d resolution djm conversion result mapping to atddr n 8-bit data 0 result-bit[11:4] = conversion result, result-bit[3:0]=0000 10-bit data 0 result-bit[11:2] = conversion result, result-bit[1:0]=00
analog-to-digital converter (adc10b16cv2) mc9s12g family reference manual, rev.1.23 542 freescale semiconductor 15.3.2.12.2 right justi?d result data (djm=1) table 15-22 shows how depending on the a/d resolution the conversion result is transferred to the atd result registers for right justi?d data. compare is always done using all 12 bits of both the conversion result and the compare value in atddrn. module base + 0x0010 = atddr0, 0x0012 = atddr1, 0x0014 = atddr2, 0x0016 = atddr3 0x0018 = atddr4, 0x001a = atddr5, 0x001c = atddr6, 0x001e = atddr7 0x0020 = atddr8, 0x0022 = atddr9, 0x0024 = atddr10, 0x0026 = atddr11 0x0028 = atddr12, 0x002a = atddr13, 0x002c = atddr14, 0x002e = atddr15 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r 0 000 result-bit[11:0] w reset 0 0 0 0 0 0 0 0 0 0000000 = unimplemented or reserved figure 15-15. right justi?d atd conversion result register (atddr n ) table 15-22. conversion result mapping to atddrn a/d resolution djm conversion result mapping to atddr n 8-bit data 1 result-bit[7:0] = result, result-bit[11:8]=0000 10-bit data 1 result-bit[9:0] = result, result-bit[11:10]=00
analog-to-digital converter (adc10b16cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 543 15.4 functional description the adc10b16c consists of an analog sub-block and a digital sub-block. 15.4.1 analog sub-block the analog sub-block contains all analog electronics required to perform a single conversion. separate power supplies vdda and vssa allow to isolate noise of other mcu circuitry from the analog sub-block. 15.4.1.1 sample and hold machine the sample and hold machine controls the storage and charge of the sample capacitor to the voltage level of the analog signal at the selected adc input channel. during the sample process the analog input connects directly to the storage node. the input analog signals are unipolar and must be within the potential range of vssa to vdda. during the hold process the analog input is disconnected from the storage node. 15.4.1.2 analog input multiplexer the analog input multiplexer connects one of the 16 external analog input channels to the sample and hold machine. 15.4.1.3 analog-to-digital (a/d) machine the a/d machine performs analog to digital conversions. the resolution is program selectable to be either 8 or 10 bits. the a/d machine uses a successive approximation architecture. it functions by comparing the sampled and stored analog voltage with a series of binary coded discrete voltages. by following a binary search algorithm, the a/d machine identi?s the discrete voltage that is nearest to the sampled and stored voltage. when not converting the a/d machine is automatically powered down. only analog input signals within the potential range of vrl to vrh (a/d reference potentials) will result in a non-railed digital output code. 15.4.2 digital sub-block this subsection describes some of the digital features in more detail. see section 15.3.2, ?egister descriptions for all details. 15.4.2.1 external trigger input the external trigger feature allows the user to synchronize atd conversions to an external event rather than relying only on software to trigger the atd module when a conversion is about to take place. the external trigger signal (out of reset atd channel 15, con?urable in atdctl1) is programmable to be
analog-to-digital converter (adc10b16cv2) mc9s12g family reference manual, rev.1.23 544 freescale semiconductor edge or level sensitive with polarity control. table 15-23 gives a brief description of the different combinations of control bits and their effect on the external trigger function. in order to avoid maybe false trigger events please enable the external digital input via atddien register ?st and in the following enable the external trigger mode by bit etrige. in either level or edge sensitive mode, the ?st conversion begins when the trigger is received. once etrige is enabled a conversion must be triggered externally after writing to atdctl5 register. during a conversion in edge sensitive mode, if additional trigger events are detected the overrun error ?g etorf is set. if level sensitive mode is active and the external trigger de-asserts and later asserts again during a conversion sequence, this does not constitute an overrun. therefore, the ?g is not set. if the trigger is left active in level sensitive mode when a sequence is about to complete, another sequence will be triggered immediately. 15.4.2.2 general-purpose digital port operation each atd input pin can be switched between analog or digital input functionality. an analog multiplexer makes each atd input pin selected as analog input available to the a/d converter. the pad of the atd input pin is always connected to the analog input channel of the analog mulitplexer. each pad input signal is buffered to the digital port register. this buffer can be turned on or off with the atddien register for each atd input pin. this is important so that the buffer does not draw excess current when an atd input pin is selected as analog input to the adc10b16c. table 15-23. external trigger control bits etrigle etrigp etrige scan description x x 0 0 ignores external trigger. performs one conversion sequence and stops. x x 0 1 ignores external trigger. performs continuous conversion sequences. 0 0 1 x trigger falling edge sensitive. performs one conversion sequence per trigger. 0 1 1 x trigger rising edge sensitive. performs one conversion sequence per trigger. 1 0 1 x trigger low level sensitive. performs continuous conversions while trigger level is active. 1 1 1 x trigger high level sensitive. performs continuous conversions while trigger level is active.
analog-to-digital converter (adc10b16cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 545 15.5 resets at reset the adc10b16c is in a power down state. the reset state of each individual bit is listed within the register description section (see section 15.3.2, ?egister descriptions ) which details the registers and their bit-?ld. 15.6 interrupts the interrupts requested by the adc10b16c are listed in table 15-24 . refer to mcu speci?ation for related vector address and priority. see section 15.3.2, ?egister descriptions for further details. table 15-24. atd interrupt vectors interrupt source ccr mask local enable sequence complete interrupt i bit ascie in atdctl2 compare interrupt i bit acmpie in atdctl2
analog-to-digital converter (adc10b16cv2) mc9s12g family reference manual, rev.1.23 546 freescale semiconductor
mc9s12g family reference manual, rev.1.23 freescale semiconductor 547 chapter 16 analog-to-digital converter (adc12b16cv2) revision history version number revision date effective date author description of changes v02.00 18 june 2009 18 june 2009 initial version copied 12 channel block guide v02.01 09 feb 2010 09 feb 2010 updated table 16-15 analog input channel select coding - description of internal channels. updated register atddr (left/right justi?d result) description in section 16.3.2.12.1/16-568 and 16.3.2.12.2/16-569 and added table 16-21 to improve feature description. fixed typo in table 16-9 - conversion result for 3mv and 10bit resolution v02.03 26 feb 2010 26 feb 2010 corrected table 16-15 analog input channel select coding - description of internal channels. v02.04 26 mar 2010 16 mar 2010 corrected typo: reset value of atddien register v02.05 14 apr 2010 14 apr 2010 corrected typos to be in-line with soc level pin naming conventions for vdda, vssa, vrl and vrh. v02.06 25 aug 2010 25 aug 2010 removed feature of conversion during stop and general wording clean up done in section 16.4, ?unctional description v02.07 09 sep 2010 09 sep 2010 update of internal only information. v02.08 11 feb 2011 11 feb 2011 connectivity information regarding internal channel_6 added to table 16-15 . v02.09 29 mar 2011 29 mar 2011 fixed typo in bit description ?ld table 16-14 for bits cd, cc, cb, ca. last sentence contained a wrong highest channel number (it is not an7 to an0 instead it is an15 to an0). v02.10 22. jun 2012 22. jun 2012 updated register wirte access information in section 16.3.2.9/16-566 v02.11 29. jun 2012 29. jun 2012 removed ip name in block diagram figure 16-1 v02.12 02 oct 2012 02 oct 2012 added user information to avoid maybe false external trigger events when enabling the external trigger mode ( section 16.4.2.1, ?xternal trigger input ).
analog-to-digital converter (adc12b16cv2) mc9s12g family reference manual, rev.1.23 548 freescale semiconductor 16.1 introduction the adc12b16c is a 16-channel, 12-bit, multiplexed input successive approximation analog-to-digital converter. refer to device electrical speci?ations for atd accuracy. 16.1.1 features 8-, 10-, or 12-bit resolution. automatic return to low power after conversion sequence automatic compare with interrupt for higher than or less/equal than programmable value programmable sample time. left/right justi?d result data. external trigger control. sequence complete interrupt. analog input multiplexer for 8 analog input channels. special conversions for vrh, vrl, (vrl+vrh)/2 and adc temperature sensor. 1-to-16 conversion sequence lengths. continuous conversion mode. multiple channel scans. con?urable external trigger functionality on any ad channel or any of four additional trigger inputs. the four additional trigger inputs can be chip external or internal. refer to device speci?ation for availability and connectivity. con?urable location for channel wrap around (when converting multiple channels in a sequence).
analog-to-digital converter (adc12b16cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 549 16.1.2 modes of operation 16.1.2.1 conversion modes there is software programmable selection between performing single or continuous conversion on a single channel or multiple channels . 16.1.2.2 mcu operating modes stop mode entering stop mode aborts any conversion sequence in progress and if a sequence was aborted restarts it after exiting stop mode. this has the same effect/consequences as starting a conversion sequence with write to atdctl5. so after exiting from stop mode with a previously aborted sequence all ?gs are cleared etc. wait mode adc12b16c behaves same in run and wait mode. for reduced power consumption continuous conversions should be aborted before entering wait mode. freeze mode in freeze mode the adc12b16c will either continue or ?ish or stop converting according to the frz1 and frz0 bits. this is useful for debugging and emulation.
analog-to-digital converter (adc12b16cv2) mc9s12g family reference manual, rev.1.23 550 freescale semiconductor 16.1.3 block diagram figure 16-1. adc12b16c block diagram vssa an9 analog mux mode and successive approximation register (sar) results atd 0 atd 1 atd 2 atd 3 atd 4 atd 5 atd 6 atd 7 and dac sample & hold vdda vrl vrh sequence complete + - comparator clock prescaler bus clock atd clock an7 an6 an5 an10 etrig0 (see device speci? cation for availability etrig1 etrig2 etrig3 and connectivity) timing control atddien atdctl1 trigger mux interrupt compare interrupt an4 an11 an12 an13 an14 atd 8 atd 9 atd 10 atd 11 atd 13 atd 14 atd 12 atd 15 an3 an2 an1 an0 an8 an15
analog-to-digital converter (adc12b16cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 551 16.2 signal description this section lists all inputs to the adc12b16c block. 16.2.1 detailed signal descriptions 16.2.1.1 an x ( x = 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) this pin serves as the analog input channel x . it can also be con?ured as digital port or external trigger for the atd conversion. 16.2.1.2 etrig3, etrig2, etrig1, etrig0 these inputs can be con?ured to serve as an external trigger for the atd conversion. refer to device speci?ation for availability and connectivity of these inputs! 16.2.1.3 vrh, vrl vrh is the high reference voltage, vrl is the low reference voltage for atd conversion. 16.2.1.4 vdda, vssa these pins are the power supplies for the analog circuitry of the adc12b16c block. 16.3 memory map and register de?ition this section provides a detailed description of all registers accessible in the adc12b16c. 16.3.1 module memory map figure 16-2 gives an overview on all adc12b16c registers. note register address = base address + address offset, where the base address is de?ed at the mcu level and the address offset is de?ed at the module level. address name bit 7 6 5 4 3 2 1 bit 0 0x0000 atdctl0 r reserved 000 wrap3 wrap2 wrap1 wrap0 w 0x0001 atdctl1 r etrigsel sres1 sres0 smp_dis etrigch3 etrigch2 etrigch1 etrigch0 w 0x0002 atdctl2 r0 affc reserved etrigle etrigp etrige ascie acmpie w = unimplemented or reserved figure 16-2. adc12b16c register summary (sheet 1 of 3)
analog-to-digital converter (adc12b16cv2) mc9s12g family reference manual, rev.1.23 552 freescale semiconductor 0x0003 atdctl3 r djm s8c s4c s2c s1c fifo frz1 frz0 w 0x0004 atdctl4 r smp2 smp1 smp0 prs[4:0] w 0x0005 atdctl5 r0 sc scan mult cd cc cb ca w 0x0006 atdstat0 r scf 0 etorf fifor cc3 cc2 cc1 cc0 w 0x0007 unimple- mented r0 000 0 0 0 0 w 0x0008 atdcmpeh r cmpe[15:8] w 0x0009 atdcmpel r cmpe[7:0] w 0x000a atdstat2h r ccf[15:8] w 0x000b atdstat2l r ccf[7:0] w 0x000c atddienh r ien[15:8] w 0x000d atddienl r ien[7:0] w 0x000e atdcmphth r cmpht[15:8] w 0x000f atdcmphtl r cmpht[7:0] w 0x0010 atddr0 r see section 16.3.2.12.1, ?eft justi?d result data (djm=0) and section 16.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0012 atddr1 r see section 16.3.2.12.1, ?eft justi?d result data (djm=0) and section 16.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0014 atddr2 r see section 16.3.2.12.1, ?eft justi?d result data (djm=0) and section 16.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0016 atddr3 r see section 16.3.2.12.1, ?eft justi?d result data (djm=0) and section 16.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0018 atddr4 r see section 16.3.2.12.1, ?eft justi?d result data (djm=0) and section 16.3.2.12.2, ?ight justi?d result data (djm=1) w 0x001a atddr5 r see section 16.3.2.12.1, ?eft justi?d result data (djm=0) and section 16.3.2.12.2, ?ight justi?d result data (djm=1) w 0x001c atddr6 r see section 16.3.2.12.1, ?eft justi?d result data (djm=0) and section 16.3.2.12.2, ?ight justi?d result data (djm=1) w 0x001e atddr7 r see section 16.3.2.12.1, ?eft justi?d result data (djm=0) and section 16.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0020 atddr8 r see section 16.3.2.12.1, ?eft justi?d result data (djm=0) and section 16.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0022 atddr9 r see section 16.3.2.12.1, ?eft justi?d result data (djm=0) and section 16.3.2.12.2, ?ight justi?d result data (djm=1) w address name bit 7 6 5 4 3 2 1 bit 0 = unimplemented or reserved figure 16-2. adc12b16c register summary (sheet 2 of 3)
analog-to-digital converter (adc12b16cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 553 0x0024 atddr10 r see section 16.3.2.12.1, ?eft justi?d result data (djm=0) and section 16.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0026 atddr11 r see section 16.3.2.12.1, ?eft justi?d result data (djm=0) and section 16.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0028 atddr12 r see section 16.3.2.12.1, ?eft justi?d result data (djm=0) and section 16.3.2.12.2, ?ight justi?d result data (djm=1) w 0x002a atddr13 r see section 16.3.2.12.1, ?eft justi?d result data (djm=0) and section 16.3.2.12.2, ?ight justi?d result data (djm=1) w 0x002c atddr14 r see section 16.3.2.12.1, ?eft justi?d result data (djm=0) and section 16.3.2.12.2, ?ight justi?d result data (djm=1) w 0x002e atddr15 r see section 16.3.2.12.1, ?eft justi?d result data (djm=0) and section 16.3.2.12.2, ?ight justi?d result data (djm=1) w w address name bit 7 6 5 4 3 2 1 bit 0 = unimplemented or reserved figure 16-2. adc12b16c register summary (sheet 3 of 3)
analog-to-digital converter (adc12b16cv2) mc9s12g family reference manual, rev.1.23 554 freescale semiconductor 16.3.2 register descriptions this section describes in address order all the adc12b16c registers and their individual bits. 16.3.2.1 atd control register 0 (atdctl0) writes to this register will abort current conversion sequence. read: anytime write: anytime, in special modes always write 0 to reserved bit 7. module base + 0x0000 76543210 r reserved 000 wrap3 wrap2 wrap1 wrap0 w reset 0 0 0 01111 = unimplemented or reserved figure 16-3. atd control register 0 (atdctl0) table 16-1. atdctl0 field descriptions field description 3-0 wrap[3-0] wrap around channel select bits ?these bits determine the channel for wrap around when doing multi-channel conversions. the coding is summarized in table 16-2 . table 16-2. multi-channel wrap around coding wrap3 wrap2 wrap1 wrap0 multiple channel conversions (mult = 1) wraparound to an0 after converting 0000 reserved 1 0001 an1 0010 an2 0011 an3 0100 an4 0101 an5 0110 an6 0111 an7 1000 an8 1001 an9 1010 an10 1011 an11 1100 an12 1101 an13 1110 an14 1111 an15
analog-to-digital converter (adc12b16cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 555 16.3.2.2 atd control register 1 (atdctl1) writes to this register will abort current conversion sequence. read: anytime write: anytime 1 if only an0 should be converted use mult=0. module base + 0x0001 76543210 r etrigsel sres1 sres0 smp_dis etrigch3 etrigch2 etrigch1 etrigch0 w reset 0 0 1 01111 figure 16-4. atd control register 1 (atdctl1) table 16-3. atdctl1 field descriptions field description 7 etrigsel external trigger source select ?this bit selects the external trigger source to be either one of the ad channels or one of the etrig3-0 inputs. see device speci?ation for availability and connectivity of etrig3-0 inputs. if a particular etrig3-0 input option is not available, writing a 1 to etrisel only sets the bit but has no effect, this means that one of the ad channels (selected by etrigch3-0) is con?ured as the source for external trigger. the coding is summarized in table 16-5 . 6? sres[1:0] a/d resolution select ?these bits select the resolution of a/d conversion results. see table 16-4 for coding. 4 smp_dis discharge before sampling bit 0 no discharge before sampling. 1 the internal sample capacitor is discharged before sampling the channel. this adds 2 atd clock cycles to the sampling time. this can help to detect an open circuit instead of measuring the previous sampled channel. 3? etrigch[3:0] external trigger channel select these bits select one of the ad channels or one of the etrig3-0 inputs as source for the external trigger. the coding is summarized in table 16-5 . table 16-4. a/d resolution coding sres1 sres0 a/d resolution 0 0 8-bit data 0 1 10-bit data 1 0 12-bit data 1 1 reserved
analog-to-digital converter (adc12b16cv2) mc9s12g family reference manual, rev.1.23 556 freescale semiconductor 16.3.2.3 atd control register 2 (atdctl2) writes to this register will abort current conversion sequence. read: anytime write: anytime table 16-5. external trigger channel select coding etrigsel etrigch3 etrigch2 etrigch1 etrigch0 external trigger source is 0 0 0 0 0 an0 0 0 0 0 1 an1 0 0 0 1 0 an2 0 0 0 1 1 an3 0 0 1 0 0 an4 0 0 1 0 1 an5 0 0 1 1 0 an6 0 0 1 1 1 an7 0 1 0 0 0 an8 0 1 0 0 1 an9 0 1 0 1 0 an10 0 1 0 1 1 an11 0 1 1 0 0 an12 0 1 1 0 1 an13 0 1 1 1 0 an14 0 1 1 1 1 an15 1 0 0 0 0 etrig0 1 1 only if etrig3-0 input option is available (see device speci?ation), else etrisel is ignored, that means external trigger source is still on one of the ad channels selected by etrigch3-0 1 0 0 0 1 etrig1 1 1 0 0 1 0 etrig2 1 1 0 0 1 1 etrig3 1 1 0 1 x x reserved 1 1 x x x reserved module base + 0x0002 76543210 r0 affc reserved etrigle etrigp etrige ascie acmpie w reset 0 0 0 00000 = unimplemented or reserved figure 16-5. atd control register 2 (atdctl2)
analog-to-digital converter (adc12b16cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 557 table 16-6. atdctl2 field descriptions field description 6 affc atd fast flag clear all 0 atd ?g clearing done by write 1 to respective ccf[ n ] ?g. 1 changes all atd conversion complete ?gs to a fast clear sequence. for compare disabled (cmpe[ n ]=0) a read access to the result register will cause the associated ccf[ n ] ?g to clear automatically. for compare enabled (cmpe[ n ]=1) a write access to the result register will cause the associated ccf[ n ] ?g to clear automatically. 5 reserved do not alter this bit from its reset value.it is for manufacturer use only and can change the atd behavior. 4 etrigle external trigger level/edge control ?this bit controls the sensitivity of the external trigger signal. see table 16-7 for details. 3 etrigp external trigger polarity this bit controls the polarity of the external trigger signal. see table 16-7 for details. 2 etrige external trigger mode enable this bit enables the external trigger on one of the ad channels or one of the etrig3-0 inputs as described in table 16-5 . if the external trigger source is one of the ad channels, the digital input buffer of this channel is enabled. the external trigger allows to synchronize the start of conversion with external events. 0 disable external trigger 1 enable external trigger 1 ascie atd sequence complete interrupt enable 0 atd sequence complete interrupt requests are disabled. 1 atd sequence complete interrupt will be requested whenever scf=1 is set. 0 acmpie atd compare interrupt enable if automatic compare is enabled for conversion n (cmpe[ n ]=1 in atdcmpe register) this bit enables the compare interrupt. if the ccf[ n ] ?g is set (showing a successful compare for conversion n ), the compare interrupt is triggered. 0 atd compare interrupt requests are disabled. 1 for the conversions in a sequence for which automatic compare is enabled (cmpe[ n ]=1), an atd compare interrupt will be requested whenever any of the respective ccf ?gs is set. table 16-7. external trigger con?urations etrigle etrigp external trigger sensitivity 0 0 falling edge 0 1 rising edge 1 0 low level 1 1 high level
analog-to-digital converter (adc12b16cv2) mc9s12g family reference manual, rev.1.23 558 freescale semiconductor 16.3.2.4 atd control register 3 (atdctl3) writes to this register will abort current conversion sequence. read: anytime write: anytime module base + 0x0003 76543210 r djm s8c s4c s2c s1c fifo frz1 frz0 w reset 0 0 1 00000 = unimplemented or reserved figure 16-6. atd control register 3 (atdctl3) table 16-8. atdctl3 field descriptions field description 7 djm result register data justi?ation ?result data format is always unsigned. this bit controls justi?ation of conversion data in the result registers. 0 left justi?d data in the result registers. 1 right justi?d data in the result registers. table 16-9 gives example atd results for an input signal range between 0 and 5.12 volts. 6? s8c, s4c, s2c, s1c conversion sequence length ?these bits control the number of conversions per sequence. table 16-10 shows all combinations. at reset, s4c is set to 1 (sequence length is 4). this is to maintain software continuity to hc12 family. 2 fifo result register fifo mode if this bit is zero (non-fifo mode), the a/d conversion results map into the result registers based on the conversion sequence; the result of the ?st conversion appears in the ?st result register (atddr0), the second result in the second result register (atddr1), and so on. if this bit is one (fifo mode) the conversion counter is not reset at the beginning or end of a conversion sequence; sequential conversion results are placed in consecutive result registers. in a continuously scanning conversion sequence, the result register counter will wrap around when it reaches the end of the result register ?e. the conversion counter value (cc3-0 in atdstat0) can be used to determine where in the result register ?e, the current conversion result will be placed. aborting a conversion or starting a new conversion clears the conversion counter even if fifo=1. so the ?st result of a new conversion sequence, started by writing to atdctl5, will always be place in the ?st result register (atdddr0). intended usage of fifo mode is continuos conversion (scan=1) or triggered conversion (etrig=1). which result registers hold valid data can be tracked using the conversion complete ?gs. fast ?g clear mode may be useful in a particular application to track valid data. if this bit is one, automatic compare of result registers is always disabled, that is adc12b16c will behave as if acmpie and all cpme[ n ] were zero. 0 conversion results are placed in the corresponding result register up to the selected sequence length. 1 conversion results are placed in consecutive result registers (wrap around at end). 1? frz[1:0] background debug freeze enable ?when debugging an application, it is useful in many cases to have the atd pause when a breakpoint (freeze mode) is encountered. these 2 bits determine how the atd will respond to a breakpoint as shown in table 16-11 . leakage onto the storage node and comparator reference capacitors may compromise the accuracy of an immediately frozen conversion depending on the length of the freeze period.
analog-to-digital converter (adc12b16cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 559 table 16-9. examples of ideal decimal atd results input signal vrl = 0 volts vrh = 5.12 volts 8-bit codes (resolution=20mv) 10-bit codes (resolution=5mv) 12-bit codes (transfer curve has 1.25mv offset) (resolution=1.25mv) 5.120 volts ... 0.022 0.020 0.018 0.016 0.014 0.012 0.010 0.008 0.006 0.004 0.003 0.002 0.000 255 ... 1 1 1 1 1 1 1 0 0 0 0 0 0 1023 ... 4 4 4 3 3 2 2 2 1 1 1 0 0 4095 ... 17 16 14 12 11 9 8 6 4 3 2 1 0 table 16-10. conversion sequence length coding s8c s4c s2c s1c number of conversions per sequence 00 0 0 16 00 0 1 1 00 1 0 2 00 1 1 3 01 0 0 4 01 0 1 5 01 1 0 6 01 1 1 7 10 0 0 8 10 0 1 9 10 1 0 10 10 1 1 11 11 0 0 12 11 0 1 13 11 1 0 14 11 1 1 15
analog-to-digital converter (adc12b16cv2) mc9s12g family reference manual, rev.1.23 560 freescale semiconductor 16.3.2.5 atd control register 4 (atdctl4) writes to this register will abort current conversion sequence. read: anytime write: anytime table 16-11. atd behavior in freeze mode (breakpoint) frz1 frz0 behavior in freeze mode 0 0 continue conversion 0 1 reserved 1 0 finish current conversion, then freeze 1 1 freeze immediately module base + 0x0004 76543210 r smp2 smp1 smp0 prs[4:0] w reset 0 0 0 00101 figure 16-7. atd control register 4 (atdctl4) table 16-12. atdctl4 field descriptions field description 7? smp[2:0] sample time select ?these three bits select the length of the sample time in units of atd conversion clock cycles. note that the atd conversion clock period is itself a function of the prescaler value (bits prs4-0). table 16-13 lists the available sample time lengths. 4? prs[4:0] atd clock prescaler these 5 bits are the binary prescaler value prs. the atd conversion clock frequency is calculated as follows: refer to device speci?ation for allowed frequency range of f atdclk . table 16-13. sample time select smp2 smp1 smp0 sample time in number of atd clock cycles 000 4 001 6 010 8 011 10 100 12 101 16 110 20 f atdclk f bus 2 prs 1 + () ------------------------------------- =
analog-to-digital converter (adc12b16cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 561 16.3.2.6 atd control register 5 (atdctl5) writes to this register will abort current conversion sequence and start a new conversion sequence. if the external trigger function is enabled (etrige=1) an initial write to atdctl5 is required to allow starting of a conversion sequence which will then occur on each trigger event. start of conversion means the beginning of the sampling phase. read: anytime write: anytime 111 24 module base + 0x0005 76543210 r0 sc scan mult cd cc cb ca w reset 0 0 0 00000 = unimplemented or reserved figure 16-8. atd control register 5 (atdctl5) table 16-14. atdctl5 field descriptions field description 6 sc special channel conversion bit if this bit is set, then special channel conversion can be selected using cd, cc, cb and ca of atdctl5. table 16-15 lists the coding. 0 special channel conversions disabled 1 special channel conversions enabled 5 scan continuous conversion sequence mode ?this bit selects whether conversion sequences are performed continuously or only once. if the external trigger function is enabled (etrige=1) setting this bit has no effect, thus the external trigger always starts a single conversion sequence. 0 single conversion sequence 1 continuous conversion sequences (scan mode) table 16-13. sample time select smp2 smp1 smp0 sample time in number of atd clock cycles
analog-to-digital converter (adc12b16cv2) mc9s12g family reference manual, rev.1.23 562 freescale semiconductor 4 mult multi-channel sample mode when mult is 0, the atd sequence controller samples only from the speci?d analog input channel for an entire conversion sequence. the analog channel is selected by channel selection code (control bits cd/cc/cb/ca located in atdctl5). when mult is 1, the atd sequence controller samples across channels. the number of channels sampled is determined by the sequence length value (s8c, s4c, s2c, s1c). the ?st analog channel examined is determined by channel selection code (cd, cc, cb, ca control bits); subsequent channels sampled in the sequence are determined by incrementing the channel selection code or wrapping around to an0 (channel 0). 0 sample only one channel 1 sample across several channels 3? cd, cc, cb, ca analog input channel select code ?these bits select the analog input channel(s). table 16-15 lists the coding used to select the various analog input channels. in the case of single channel conversions (mult=0), this selection code speci?s the channel to be examined. in the case of multiple channel conversions (mult=1), this selection code speci?s the ?st channel to be examined in the conversion sequence. subsequent channels are determined by incrementing the channel selection code or wrapping around to an0 (after converting the channel de?ed by the wrap around channel select bits wrap3-0 in atdctl0). when starting with a channel number higher than the one de?ed by wrap3-0 the ?st wrap around will be an16 to an0. table 16-15. analog input channel select coding sc cd cc cb ca analog input channel 00000 an0 0001 an1 0010 an2 0011 an3 0100 an4 0101 an5 0110 an6 0111 an7 1000 an8 1001 an9 1 0 1 0 an10 1 0 1 1 an11 1 1 0 0 an12 1 1 0 1 an13 1 1 1 0 an14 1 1 1 1 an15 table 16-14. atdctl5 field descriptions (continued) field description
analog-to-digital converter (adc12b16cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 563 1 0 0 0 0 internal_6, temperature sense of adc hardmacro 0 0 0 1 internal_7 0 0 1 0 internal_0 0 0 1 1 internal_1 0100 vrh 0101 vrl 0 1 1 0 (vrh+vrl) / 2 0 1 1 1 reserved 1 0 0 0 internal_2 1 0 0 1 internal_3 1 0 1 0 internal_4 1 0 1 1 internal_5 1 1 x x reserved table 16-15. analog input channel select coding sc cd cc cb ca analog input channel
analog-to-digital converter (adc12b16cv2) mc9s12g family reference manual, rev.1.23 564 freescale semiconductor 16.3.2.7 atd status register 0 (atdstat0) this register contains the sequence complete flag, overrun ?gs for external trigger and fifo mode, and the conversion counter. read: anytime write: anytime (no effect on (cc3, cc2, cc1, cc0)) module base + 0x0006 76543210 r scf 0 etorf fifor cc3 cc2 cc1 cc0 w reset 0 0 0 00000 = unimplemented or reserved figure 16-9. atd status register 0 (atdstat0) table 16-16. atdstat0 field descriptions field description 7 scf sequence complete flag ?this ?g is set upon completion of a conversion sequence. if conversion sequences are continuously performed (scan=1), the ?g is set after each one is completed. this ?g is cleared when one of the following occurs: a) write ??to scf b) write to atdctl5 (a new conversion sequence is started) c) if affc=1 and a result register is read 0 conversion sequence not completed 1 conversion sequence has completed 5 etorf external trigger overrun flag ?while in edge sensitive mode (etrigle=0), if additional active edges are detected while a conversion sequence is in process the overrun ?g is set. this ?g is cleared when one of the following occurs: a) write ??to etorf b) write to atdctl0,1,2,3,4, atdcmpe or atdcmpht (a conversion sequence is aborted) c) write to atdctl5 (a new conversion sequence is started) 0 no external trigger overrun error has occurred 1 external trigger overrun error has occurred 4 fifor result register overrun flag this bit indicates that a result register has been written to before its associated conversion complete ?g (ccf) has been cleared. this ?g is most useful when using the fifo mode because the ?g potentially indicates that result registers are out of sync with the input channels. however, it is also practical for non-fifo modes, and indicates that a result register has been overwritten before it has been read (i.e. the old data has been lost). this ?g is cleared when one of the following occurs: a) write ??to fifor b) write to atdctl0,1,2,3,4, atdcmpe or atdcmpht (a conversion sequence is aborted) c) write to atdctl5 (a new conversion sequence is started) 0 no overrun has occurred 1 overrun condition exists (result register has been written while associated ccfx ?g was still set)
analog-to-digital converter (adc12b16cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 565 16.3.2.8 atd compare enable register (atdcmpe) writes to this register will abort current conversion sequence. read: anytime write: anytime 3? cc[3:0] conversion counter these 4 read-only bits are the binary value of the conversion counter. the conversion counter points to the result register that will receive the result of the current conversion. e.g. cc3=0, cc2=1, cc1=1, cc0=0 indicates that the result of the current conversion will be in atd result register 6. if in non-fifo mode (fifo=0) the conversion counter is initialized to zero at the beginning and end of the conversion sequence. if in fifo mode (fifo=1) the register counter is not initialized. the conversion counter wraps around when its maximum value is reached. aborting a conversion or starting a new conversion clears the conversion counter even if fifo=1. module base + 0x0008 15 14 13 11 10 9 8 7 6 5 4 3 2 1 0 r cmpe[15:0] w reset 0 0 0 0 0 0 0 0 0 0000000 = unimplemented or reserved figure 16-10. atd compare enable register (atdcmpe) table 16-17. atdcmpe field descriptions field description 15? cmpe[15:0] compare enable for conversion number n ( n = 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) of a sequence ( n conversion number, not channel number!) these bits enable automatic compare of conversion results individually for conversions of a sequence. the sense of each comparison is determined by the cmpht[ n ] bit in the atdcmpht register. for each conversion number with cmpe[ n ]=1 do the following: 1) write compare value to atddr n result register 2) write compare operator with cmpht[ n ] in atdcpmht register ccf[ n ] in atdstat2 register will ?g individual success of any comparison. 0 no automatic compare 1 automatic compare of results for conversion n of a sequence is enabled. table 16-16. atdstat0 field descriptions (continued) field description
analog-to-digital converter (adc12b16cv2) mc9s12g family reference manual, rev.1.23 566 freescale semiconductor 16.3.2.9 atd status register 2 (atdstat2) this read-only register contains the conversion complete flags ccf[15:0]. read: anytime write: anytime (for details see table 16-18 below) module base + 0x000a 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r ccf[15:0] w reset 0 0 0 0 0 0 0 0 0 0000000 = unimplemented or reserved figure 16-11. atd status register 2 (atdstat2) table 16-18. atdstat2 field descriptions field description 15? ccf[15:0] conversion complete flag n ( n = 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) ( n conversion number, not channel number!) a conversion complete ?g is set at the end of each conversion in a sequence. the ?gs are associated with the conversion position in a sequence (and also the result register number). therefore in non-?o mode, ccf[4] is set when the ?th conversion in a sequence is complete and the result is available in result register atddr4; ccf[5] is set when the sixth conversion in a sequence is complete and the result is available in atddr5, and so forth. if automatic compare of conversion results is enabled (cmpe[ n ]=1 in atdcmpe), the conversion complete ?g is only set if comparison with atddr n is true. if acmpie=1 a compare interrupt will be requested. in this case, as the atddr n result register is used to hold the compare value, the result will not be stored there at the end of the conversion but is lost. a ?g ccf[ n ] is cleared when one of the following occurs: a) write to atdctl5 (a new conversion sequence is started) b) if affc=0, write ??to ccf[ n ] c) if affc=1 and cmpe[ n ]=0, read of result register atddr n d) if affc=1 and cmpe[ n ]=1, write to result register atddr n in case of a concurrent set and clear on ccf[ n ]: the clearing by method a) will overwrite the set. the clearing by methods b) or c) or d) will be overwritten by the set. 0 conversion number n not completed or successfully compared 1 if (cmpe[ n ]=0): conversion number n has completed. result is ready in atddr n . if (cmpe[ n ]=1): compare for conversion result number n with compare value in atddr n , using compare operator cmpgt[ n ] is true. (no result available in atddr n )
analog-to-digital converter (adc12b16cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 567 16.3.2.10 atd input enable register (atddien) read: anytime write: anytime 16.3.2.11 atd compare higher than register (atdcmpht) writes to this register will abort current conversion sequence. read: anytime write: anytime module base + 0x000c 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r ien[15:0] w reset 0 0 0 0 0 0 0 0 0 0000000 = unimplemented or reserved figure 16-12. atd input enable register (atddien) table 16-19. atddien field descriptions field description 15? ien[15:0] atd digital input enable on channel x ( x = 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) this bit controls the digital input buffer from the analog input pin (an x ) to the digital data register. 0 disable digital input buffer to an x pin 1 enable digital input buffer on an x pin. note: setting this bit will enable the corresponding digital input buffer continuously. if this bit is set while simultaneously using it as an analog port, there is potentially increased power consumption because the digital input buffer maybe in the linear region. module base + 0x000e 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r cmpht[15:0] w reset 0 0 0 0 0 0 0 0 0 0000000 = unimplemented or reserved figure 16-13. atd compare higher than register (atdcmpht) table 16-20. atdcmpht field descriptions field description 15? cmpht[15:0] compare operation higher than enable for conversion number n ( n = 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) of a sequence ( n conversion number, not channel number!) this bit selects the operator for comparison of conversion results. 0 if result of conversion n is lower or same than compare value in atddr n , this is ?gged in atdstat2 1 if result of conversion n is higher than compare value in atddr n , this is ?gged in atdstat2
analog-to-digital converter (adc12b16cv2) mc9s12g family reference manual, rev.1.23 568 freescale semiconductor 16.3.2.12 atd conversion result registers (atddr n ) the a/d conversion results are stored in 16 result registers. results are always in unsigned data representation. left and right justi?ation is selected using the djm control bit in atdctl3. if automatic compare of conversions results is enabled (cmpe[ n ]=1 in atdcmpe), these registers must be written with the compare values in left or right justi?d format depending on the actual value of the djm bit. in this case, as the atddr n register is used to hold the compare value, the result will not be stored there at the end of the conversion but is lost. attention, n is the conversion number, not the channel number! read: anytime write: anytime note for conversions not using automatic compare, results are stored in the result registers after each conversion. in this case avoid writing to atddrn except for initial values, because an a/d result might be overwritten. 16.3.2.12.1 left justi?d result data (djm=0) table 16-21 shows how depending on the a/d resolution the conversion result is transferred to the atd result registers for left justi?d data. compare is always done using all 12 bits of both the conversion result and the compare value in atddrn. module base + 0x0010 = atddr0, 0x0012 = atddr1, 0x0014 = atddr2, 0x0016 = atddr3 0x0018 = atddr4, 0x001a = atddr5, 0x001c = atddr6, 0x001e = atddr7 0x0020 = atddr8, 0x0022 = atddr9, 0x0024 = atddr10, 0x0026 = atddr11 0x0028 = atddr12, 0x002a = atddr13, 0x002c = atddr14, 0x002e = atddr15 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r result-bit[11:0] 0 000 w reset 0 0 0 0 0 0 0 0 0 0000000 = unimplemented or reserved figure 16-14. left justi?d atd conversion result register (atddr n ) table 16-21. conversion result mapping to atddrn a/d resolution djm conversion result mapping to atddr n 8-bit data 0 result-bit[11:4] = conversion result, result-bit[3:0]=0000 10-bit data 0 result-bit[11:2] = conversion result, result-bit[1:0]=00 12-bit data 0 result-bit[11:0] = result
analog-to-digital converter (adc12b16cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 569 16.3.2.12.2 right justi?d result data (djm=1) table 16-22 shows how depending on the a/d resolution the conversion result is transferred to the atd result registers for right justi?d data. compare is always done using all 12 bits of both the conversion result and the compare value in atddrn. module base + 0x0010 = atddr0, 0x0012 = atddr1, 0x0014 = atddr2, 0x0016 = atddr3 0x0018 = atddr4, 0x001a = atddr5, 0x001c = atddr6, 0x001e = atddr7 0x0020 = atddr8, 0x0022 = atddr9, 0x0024 = atddr10, 0x0026 = atddr11 0x0028 = atddr12, 0x002a = atddr13, 0x002c = atddr14, 0x002e = atddr15 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r 0 000 result-bit[11:0] w reset 0 0 0 0 0 0 0 0 0 0000000 = unimplemented or reserved figure 16-15. right justi?d atd conversion result register (atddr n ) table 16-22. conversion result mapping to atddrn a/d resolution djm conversion result mapping to atddr n 8-bit data 1 result-bit[7:0] = result, result-bit[11:8]=0000 10-bit data 1 result-bit[9:0] = result, result-bit[11:10]=00 12-bit data 1 result-bit[11:0] = result
analog-to-digital converter (adc12b16cv2) mc9s12g family reference manual, rev.1.23 570 freescale semiconductor 16.4 functional description the adc12b16c consists of an analog sub-block and a digital sub-block. 16.4.1 analog sub-block the analog sub-block contains all analog electronics required to perform a single conversion. separate power supplies vdda and vssa allow to isolate noise of other mcu circuitry from the analog sub-block. 16.4.1.1 sample and hold machine the sample and hold machine controls the storage and charge of the sample capacitor to the voltage level of the analog signal at the selected adc input channel. during the sample process the analog input connects directly to the storage node. the input analog signals are unipolar and must be within the potential range of vssa to vdda. during the hold process the analog input is disconnected from the storage node. 16.4.1.2 analog input multiplexer the analog input multiplexer connects one of the 16 external analog input channels to the sample and hold machine. 16.4.1.3 analog-to-digital (a/d) machine the a/d machine performs analog to digital conversions. the resolution is program selectable to be either 8 or 10 or 12 bits. the a/d machine uses a successive approximation architecture. it functions by comparing the sampled and stored analog voltage with a series of binary coded discrete voltages. by following a binary search algorithm, the a/d machine identi?s the discrete voltage that is nearest to the sampled and stored voltage. when not converting the a/d machine is automatically powered down. only analog input signals within the potential range of vrl to vrh (a/d reference potentials) will result in a non-railed digital output code. 16.4.2 digital sub-block this subsection describes some of the digital features in more detail. see section 16.3.2, ?egister descriptions for all details. 16.4.2.1 external trigger input the external trigger feature allows the user to synchronize atd conversions to an external event rather than relying only on software to trigger the atd module when a conversion is about to take place. the external trigger signal (out of reset atd channel 15, con?urable in atdctl1) is programmable to be
analog-to-digital converter (adc12b16cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 571 edge or level sensitive with polarity control. table 16-23 gives a brief description of the different combinations of control bits and their effect on the external trigger function. in order to avoid maybe false trigger events please enable the external digital input via atddien register ?st and in the following enable the external trigger mode by bit etrige. in either level or edge sensitive mode, the ?st conversion begins when the trigger is received. once etrige is enabled a conversion must be triggered externally after writing to atdctl5 register. during a conversion in edge sensitive mode, if additional trigger events are detected the overrun error ?g etorf is set. if level sensitive mode is active and the external trigger de-asserts and later asserts again during a conversion sequence, this does not constitute an overrun. therefore, the ?g is not set. if the trigger is left active in level sensitive mode when a sequence is about to complete, another sequence will be triggered immediately. 16.4.2.2 general-purpose digital port operation each atd input pin can be switched between analog or digital input functionality. an analog multiplexer makes each atd input pin selected as analog input available to the a/d converter. the pad of the atd input pin is always connected to the analog input channel of the analog mulitplexer. each pad input signal is buffered to the digital port register. this buffer can be turned on or off with the atddien register for each atd input pin. this is important so that the buffer does not draw excess current when an atd input pin is selected as analog input to the adc12b16c. table 16-23. external trigger control bits etrigle etrigp etrige scan description x x 0 0 ignores external trigger. performs one conversion sequence and stops. x x 0 1 ignores external trigger. performs continuous conversion sequences. 0 0 1 x trigger falling edge sensitive. performs one conversion sequence per trigger. 0 1 1 x trigger rising edge sensitive. performs one conversion sequence per trigger. 1 0 1 x trigger low level sensitive. performs continuous conversions while trigger level is active. 1 1 1 x trigger high level sensitive. performs continuous conversions while trigger level is active.
analog-to-digital converter (adc12b16cv2) mc9s12g family reference manual, rev.1.23 572 freescale semiconductor 16.5 resets at reset the adc12b16c is in a power down state. the reset state of each individual bit is listed within the register description section (see section 16.3.2, ?egister descriptions ) which details the registers and their bit-?ld. 16.6 interrupts the interrupts requested by the adc12b16c are listed in table 16-24 . refer to mcu speci?ation for related vector address and priority. see section 16.3.2, ?egister descriptions for further details. table 16-24. atd interrupt vectors interrupt source ccr mask local enable sequence complete interrupt i bit ascie in atdctl2 compare interrupt i bit acmpie in atdctl2
mc9s12g family reference manual, rev.1.23 freescale semiconductor 573 chapter 17 digital analog converter (dac_8b5v) 17.1 revision history glossary table 17-1. revision history table rev. no. (item no.) data sections affected substantial change(s) 0.1 28-oct.-09 all initial version 0.4 28-oct.-09 (thomas becker) all initial version 0.5 12-nov.-09 (thomas becker) all reworked all sections, renamed pin names 0.6 17-nov.-09 (thomas becker) 1.2.4 added cpu stop mode 0.7 18-nov.-09 (thomas becker) 1.2, 1.3 update block diagram, removed analog and digital submodule, added section 1.3 0.8 04-dec.-09 (thomas becker) 1.4.2 - changed reset value of fvr bit to 1?1 - added new bit ?oad?to dacctl register - removed s3 switch description 0.9 05-jan.-10 (thomas becker) 1.3, 1.4.2.1, 1.5 - renamed register bit ?oad to ?rive? request by analog team - renamed pin dac to dacu 0.91 13-jan.-10 (thomas becker) 1.4.2.3 - added debug register 0.92 12-feb.-10 (thomas becker) all - ?ed typo 1.0 12-apr.-10 1.4.2.1 added dacctl register bit dacdien 1.01 04-may-10, table 1.2, section 1.4 replaced vrl,vrl with variable correct wrong ?ure, table numbering 1.02 12-may-10 section 1.4 replaced ipt_test_mode with ips_test_access new description/address of dacdebug register 1.1 25-may-10 17.4.2.1 removed dacctl register bit dacdien 1.2 25-jun.-10 17.4 correct table and ?ure title format 1.3 29-jul.-10 17.2 fixed typos 1.4 17-nov.-10 17.2.2 update the behavior of the dacu pin during stop mode table 17-2. terminology term meaning dac digital to analog converter vrl low reference voltage
digital analog converter (dac_8b5v) mc9s12g family reference manual, rev.1.23 574 freescale semiconductor 17.2 introduction the dac_8b5v module is a digital to analog converter. the converter works with a resolution of 8 bit and generates an output voltage between vrl and vrh. the module consists of con?uration registers and two analog functional units, a dac resistor network and an operational ampli?r. the con?uration registers provide all required control bits for the dac resistor network and for the operational ampli?r. the dac resistor network generates the desired analog output voltage. the unbuffered voltage from the dac resistor network output can be routed to the external dacu pin. when enabled, the buffered voltage from the operational ampli?r output is available on the external amp pin. the operational ampli?r is also stand alone usable. figure 17-1 shows the block diagram of the dac_8b5v module. 17.2.1 features the dac_8b5v module includes these distinctive features: 1 digital-analog converter channel with: 8 bit resolution full and reduced output voltage range buffered or unbuffered analog output voltage usable operational ampli?r stand alone usable 17.2.2 modes of operation the dac_8b5v module behaves as follows in the system power modes: 1. cpu run mode the functionality of the dac_8b5v module is available. 2. cpu stop mode independent from the mode settings, the operational ampli?r is disabled, switch s1 and s2 are open. vrh high reference voltage fvr full voltage range ssc special single chip table 17-2. terminology (continued) term meaning
digital analog converter (dac_8b5v) mc9s12g family reference manual, rev.1.23 freescale semiconductor 575 if the ?nbuffered dac mode was used before entering stop mode, then the dacu pin will reach vrh voltage level during stop mode. the content of the con?uration registers is unchanged. 17.2.3 block diagram figure 17-1. dac_8b5v block diagram 17.3 external signal description this section lists the name and description of all external ports. 17.3.1 dacu output pin this analog pin drives the unbuffered analog output voltage from the dac resistor network output, if the according mode is selected. 17.3.2 amp output pin this analog pin is used for the buffered analog output voltage from the operational ampli?r output, if the according mode is selected. 17.3.3 ampp input pin this analog input pin is used as input signal for the operational ampli?r positive input pin, if the according mode is selected. + internal bus operational ampli?r resistor network dacu ampm amp ampp s1 s1 s2 s2 con?uration registers dac s3 vrh vrl
digital analog converter (dac_8b5v) mc9s12g family reference manual, rev.1.23 576 freescale semiconductor 17.3.4 ampm input pin this analog pin is used as input for the operational ampli?r negative input pin, if the according mode is selected. 17.4 memory map and register de?ition this sections provides the detailed information of all registers for the dac_8b5v module. 17.4.1 register summary figure 17-2 shows the summary of all implemented registers inside the dac_8b5v module. note register address = module base address + address offset, where the module base address is de?ed at the mcu level and the address offset is de?ed at the module level. 17.4.2 register descriptions this section consists of register descriptions in address order. each description includes a standard register diagram with an associated ?ure number. details of register bit and ?ld function follow the register diagrams, in bit order. address offset register name bit 7 6 5 4 3 2 1 bit 0 0x0000 dacctl r fvr drive 000 dacm[2:0] w 0x0001 reserved r00000000 w 0x0002 dacvol r voltage[7:0] w 0x0003 - 0x0006 reserved r00000000 w 0x0007 reserved r reserved reserved reserved reserved reserved reserved reserved reserved w = unimplemented figure 17-2. dac_8b5v register summaryfv_dac_8b5v_reserved
digital analog converter (dac_8b5v) mc9s12g family reference manual, rev.1.23 freescale semiconductor 577 17.4.2.1 control register (dacctl) ) module base + 0x0000 access: user read/write 1 1 read: anytime write: anytime 76543210 r fvr drive 0 00 dacm[2:0] w reset 10000000 = unimplemented figure 17-3. control register (dacctl) table 17-3. dacctl field description field description 7 fvr full voltage range ?this bit de?es the voltage range of the dac. 0 dac resistor network operates with the reduced voltage range 1 dac resistor network operates with the full voltage range note: for more details see section 17.5.7, ?nalog output voltage calculation ? 6 drive drive select ?this bit selects the output drive capability of the operational ampli?r, see electrical spec. for more details. 0 low output drive for high resistive loads 1 high output drive for low resistive loads 2:0 dacm[2:0] mode select these bits de?e the mode of the dac. a write access with an unsupported mode will be ignored. 000 off 001 operational ampli?r 100 unbuffered dac 101 unbuffered dac with operational ampli?r 111 buffered dac other reserved
digital analog converter (dac_8b5v) mc9s12g family reference manual, rev.1.23 578 freescale semiconductor 17.4.2.2 analog output voltage level register (dacvol) 17.4.2.3 reserved register 17.5 functional description 17.5.1 functional overview the dac resistor network and the operational ampli?r can be used together or stand alone. following modes are supported: module base + 0x0002 access: user read/write 1 1 read: anytime write: anytime 76543210 r voltage[7:0] w reset 00000000 figure 17-4. analog output voltage level register (dacvol) table 17-4. dacvol field description field description 7:0 voltage[7:0] voltage ?this register de?es (together with the fvr bit) the analog output voltage. for more detail see equation 17-1 and equation 17-2 . module base + 0x0007 access: user read/write 1 1 read: anytime write: only in special mode 76543210 r reserved reserved reserved reserved reserved reserved reserved reserved w reset xxxxxxxx figure 17-5. reserved registerfv_dac_8b5v_reserved table 17-5. dac modes of operation dacm[2:0] description submodules output dac resistor network operational ampli?r dacu amp off 000 disabled disabled disconnected disconnected
digital analog converter (dac_8b5v) mc9s12g family reference manual, rev.1.23 freescale semiconductor 579 the dac resistor network itself can work on two different voltage ranges: table 17-7 shows the control signal decoding for each mode. for more detailed mode description see the sections below. 17.5.2 mode ?ff the ?ff mode is the default mode after reset and is selected by dacctl.dacm[2:0] = 0x0. during this mode the dac resistor network and the operational ampli?r are disabled and all switches are open. this mode provides the lowest power consumption. for decoding of the control signals see table 17-7 . 17.5.3 mode ?perational ampli?r the ?perational ampli?r?mode is selected by dacctl.dacm[2:0] = 0x1. during this mode the operational ampli?r can be used independent from the dac resister network. all required ampli?r signals, amp, ampp and ampm are available on the pins. the dac resistor network output is disconnected from the dacu pin. the connection between the ampli?r output and the negative ampli?r input is open. for decoding of the control signals see table 17-7 . operational ampli?r 001 disabled enabled disabled depend on ampp and ampm input unbuffered dac 100 enabled disabled unbuffered resistor output voltage disconnected unbuffered dac with operational ampli?r 101 enabled enabled unbuffered resistor output voltage depend on ampp and ampm input buffered dac 111 enabled enabled disconnected buffered resistor output voltage table 17-6. dac resistor network voltage ranges dac mode description full voltage range (fvr) dac resistor network provides a output voltage over the complete input voltage range, default after reset reduced voltage range dac resistor network provides a output voltage over a reduced input voltage range table 17-7. dac control signals dacm dac resistor network operational ampli?r switch s1 switch s2 switch s3 off 000 disabled disabled open open open operational ampli?r 001 disabled enabled closed open open unbuffered dac 100 enabled disabled open open closed unbuffered dac with operational ampli?r 101 enabled enabled closed open closed buffered dac 111 enabled enabled open closed open table 17-5. dac modes of operation
digital analog converter (dac_8b5v) mc9s12g family reference manual, rev.1.23 580 freescale semiconductor 17.5.4 mode ?nbuffered dac the ?nbuffered dac?mode is selected by daccntl.dacm[2:0] = 0x4. during this mode the unbuffered analog voltage from the dac resistor network output is available on the dacu output pin. the operational ampli?r is disabled and the operational ampli?r signals are disconnected from the amp pins. for decoding of the control signals see table 17-7 . 17.5.5 mode ?nbuffered dac with operational ampli?r the ?nbuffered dac with operational ampli?r?mode is selected by dacctl.dacm[2:0] = 0x5. during this mode the dac resistor network and the operational ampli?r are enabled and usable independent from each other. the unbuffered analog voltage from the dac resistor network output is available on the dacu output pin. the operational ampli?r is disconnected from the dac resistor network. all required ampli?r signals, amp, ampp and ampm are available on the pins. the connection between the ampli?r output and the negative ampli?r input is open. for decoding of the control signals see table 17-7 . 17.5.6 mode ?uffered dac the ?uffered dac?mode is selected by dacctl.dacm[2:0] = 0x7. during this is mode the dac resistor network and the operational ampli?r are enabled. the analog output voltage from the dac resistor network output is buffered by the operational ampli?r and is available on the amp output pin. the dac resistor network output is disconnected from the dacu pin. for the decoding of the control signals see table 17-7 . 17.5.7 analog output voltage calculation the dac can provide an analog output voltage in two different voltage ranges: fvr = 0, reduced voltage range the dac generates an analog output voltage inside the range from 0.1 x (vrh - vrl) + vrl to 0.9 x (vrh-vrl) + vrl with a resolution ((vrh-vrl) x 0.8) / 256, see equation below: analog output voltage = volatge[7:0] x ((vrh-vrl) x 0.8) / 256) + 0.1 x (vrh-vrl) + vrl eqn. 17-1 fvr = 1, full voltage range the dac generates an analog output voltage inside the range from vrl to vrh with a resolution (vrh-vrl) / 256, see equation below: analog output voltage = voltage[7:0] x (vrh-vrl) / 256 +vrl eqn. 17-2
digital analog converter (dac_8b5v) mc9s12g family reference manual, rev.1.23 freescale semiconductor 581 see table 17-8 for an example for vrl = 0.0 v and vrh = 5.0 v. table 17-8. analog output voltage calculation fvr min. voltage max. voltage resolution equation 0 0.5v 4.484v 15.625mv voltage[7:0] x (4.0v) / 256) + 0.5v 1 0.0v 4.980v 19.531mv voltage[7:0] x (5.0v) / 256
digital analog converter (dac_8b5v) mc9s12g family reference manual, rev.1.23 freescale semiconductor 582
digital analog converter (dac_8b5v) mc9s12g family reference manual, rev.1.23 freescale semiconductor 583
digital analog converter (dac_8b5v) mc9s12g family reference manual, rev.1.23 freescale semiconductor 584
mc9s12g family reference manual, rev.1.23 freescale semiconductor 585 chapter 18 freescales scalable controller area network (s12mscanv3) 18.1 introduction freescales scalable controller area network (s12mscanv3) de?ition is based on the mscan12 de?ition, which is the speci? implementation of the mscan concept targeted for the m68hc12 microcontroller family. the module is a communication controller implementing the can 2.0a/b protocol as de?ed in the bosch speci?ation dated september 1991. for users to fully understand the mscan speci?ation, it is recommended that the bosch speci?ation be read ?st to familiarize the reader with the terms and concepts contained within this document. though not exclusively intended for automotive applications, can protocol is designed to meet the speci? requirements of a vehicle serial data bus: real-time processing, reliable operation in the emi environment of a vehicle, cost-effectiveness, and required bandwidth. mscan uses an advanced buffer arrangement resulting in predictable real-time behavior and simpli?d application software. table 18-1. revision history revision number revision date sections affected description of changes v03.11 31 mar 2009 orthographic corrections v03.12 09 aug 2010 table 18-37 added ?osch can 2.0a/b?to bit time settings table v03.13 03 mar 2011 figure 18-4 table 18-3 corrected cane write restrictions removed footnote from rxfrm bit
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 586 freescale semiconductor 18.1.1 glossary 18.1.2 block diagram figure 18-1. mscan block diagram table 18-2. terminology ack acknowledge of can message can controller area network crc cyclic redundancy code eof end of frame fifo first-in-first-out memory ifs inter-frame sequence sof start of frame cpu bus cpu related read/write data bus can bus can protocol related serial bus oscillator clock direct clock from external oscillator bus clock cpu bus related clock can clock can protocol related clock rxcan txcan receive/ transmit engine message filtering and buffering control and status wake-up interrupt req. errors interrupt req. receive interrupt req. transmit interrupt req. canclk bus clock con?uration oscillator clock mux presc. tq clk mscan low pass filter wake-up registers
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 587 18.1.3 features the basic features of the mscan are as follows: implementation of the can protocol ?version 2.0a/b standard and extended data frames zero to eight bytes data length programmable bit rate up to 1 mbps 1 support for remote frames five receive buffers with fifo storage scheme three transmit buffers with internal prioritization using a ?ocal priority?concept flexible maskable identi?r ?ter supports two full-size (32-bit) extended identi?r ?ters, or four 16-bit ?ters, or eight 8-bit ?ters programmable wake-up functionality with integrated low-pass ?ter programmable loopback mode supports self-test operation programmable listen-only mode for monitoring of can bus programmable bus-off recovery functionality separate signalling and interrupt capabilities for all can receiver and transmitter error states (warning, error passive, bus-off) programmable mscan clock source either bus clock or oscillator clock internal timer for time-stamping of received and transmitted messages three low-power modes: sleep, power down, and mscan enable global initialization of con?uration registers 18.1.4 modes of operation for a description of the speci? mscan modes and the module operation related to the system operating modes refer to section 18.4.4, ?odes of operation ? 18.2 external signal description the mscan uses two external pins. note on mcus with an integrated can physical interface (transceiver) the mscan interface is connected internally to the transceiver interface. in these cases the external availability of signals txcan and rxcan is optional. 18.2.1 rxcan ?can receiver input pin rxcan is the mscan receiver input pin. 1. depending on the actual bit timing and the clock jitter of the pll.
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 588 freescale semiconductor 18.2.2 txcan ?can transmitter output pin txcan is the mscan transmitter output pin. the txcan output pin represents the logic level on the can bus: 0 = dominant state 1 = recessive state 18.2.3 can system a typical can system with mscan is shown in figure 18-2 . each can station is connected physically to the can bus lines through a transceiver device. the transceiver is capable of driving the large current needed for the can bus and has current protection against defective can or defective stations. figure 18-2. can system 18.3 memory map and register de?ition this section provides a detailed description of all registers accessible in the mscan. 18.3.1 module memory map figure 18-3 gives an overview on all registers and their individual bits in the mscan memory map. the register address results from the addition of base address and address offset . the base address is determined at the mcu level and can be found in the mcu memory map description. the address offset is de?ed at the module level. the mscan occupies 64 bytes in the memory space. the base address of the mscan module is determined at the mcu level when the mcu is de?ed. the register decode map is ?ed and begins at the ?st address of the module address offset. can bus can controller (mscan) transceiver can node 1 can node 2 can node n canl canh mcu txcan rxcan
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 589 the detailed register descriptions follow in the order they appear in the register map. register name bit 7 6 5 4 3 2 1 bit 0 0x0000 canctl0 r rxfrm rxact cswai synch time wupe slprq initrq w 0x0001 canctl1 r cane clksrc loopb listen borm wupm slpak initak w 0x0002 canbtr0 r sjw1 sjw0 brp5 brp4 brp3 brp2 brp1 brp0 w 0x0003 canbtr1 r samp tseg22 tseg21 tseg20 tseg13 tseg12 tseg11 tseg10 w 0x0004 canrflg r wupif cscif rstat1 rstat0 tstat1 tstat0 ovrif rxf w 0x0005 canrier r wupie cscie rstate1 rstate0 tstate1 tstate0 ovrie rxfie w 0x0006 cantflg r0 0 0 00 txe2 txe1 txe0 w 0x0007 cantier r00000 txeie2 txeie1 txeie0 w 0x0008 cantarq r00000 abtrq2 abtrq1 abtrq0 w 0x0009 cantaak r00000 abtak2 abtak1 abtak0 w 0x000a cantbsel r00000 tx2 tx1 tx0 w 0x000b canidac r0 0 idam1 idam0 0 idhit2 idhit1 idhit0 w 0x000c reserved r00000000 w 0x000d canmisc r0000000 bohold w = unimplemented or reserved figure 18-3. mscan register summary
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 590 freescale semiconductor 18.3.2 register descriptions this section describes in detail all the registers and register bits in the mscan module. each description includes a standard register diagram with an associated ?ure number. details of register bit and ?ld function follow the register diagrams, in bit order. all bits of all registers in this module are completely synchronous to internal clocks during a register read. 18.3.2.1 mscan control register 0 (canctl0) the canctl0 register provides various control bits of the mscan module as described below. 0x000e canrxerr r rxerr7 rxerr6 rxerr5 rxerr4 rxerr3 rxerr2 rxerr1 rxerr0 w 0x000f cantxerr r txerr7 txerr6 txerr5 txerr4 txerr3 txerr2 txerr1 txerr0 w 0x0010?x0013 canidar0? r ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 w 0x0014?x0017 canidmrx r am7 am6 am5 am4 am3 am2 am1 am0 w 0x0018?x001b canidar4? r ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 w 0x001c?x001f canidmr4? r am7 am6 am5 am4 am3 am2 am1 am0 w 0x0020?x002f canrxfg r see section 18.3.3, ?rogrammers model of message storage w 0x0030?x003f cantxfg r see section 18.3.3, ?rogrammers model of message storage w register name bit 7 6 5 4 3 2 1 bit 0 = unimplemented or reserved figure 18-3. mscan register summary (continued)
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 591 note the canctl0 register, except wupe, initrq, and slprq, is held in the reset state when the initialization mode is active (initrq = 1 and initak = 1). this register is writable again as soon as the initialization mode is exited (initrq = 0 and initak = 0). module base + 0x0000 access: user read/write 1 1 read: anytime write: anytime when out of initialization mode; exceptions are read-only rxact and synch, rxfrm (which is set by the module only), and initrq (which is also writable in initialization mode) 76543210 r rxfrm rxact cswai synch time wupe slprq initrq w reset: 00000001 = unimplemented figure 18-4. mscan control register 0 (canctl0) table 18-3. canctl0 register field descriptions field description 7 rxfrm received frame flag this bit is read and clear only. it is set when a receiver has received a valid message correctly, independently of the ?ter con?uration. after it is set, it remains set until cleared by software or reset. clearing is done by writing a 1. writing a 0 is ignored. this bit is not valid in loopback mode. 0 no valid message was received since last clearing this ?g 1 a valid message was received since last clearing of this ?g 6 rxact receiver active status ?this read-only ?g indicates the mscan is receiving a message 1 . the ?g is controlled by the receiver front end. this bit is not valid in loopback mode. 0 mscan is transmitting or idle 1 mscan is receiving a message (including when arbitration is lost) 5 cswai 2 can stops in wait mode enabling this bit allows for lower power consumption in wait mode by disabling all the clocks at the cpu bus interface to the mscan module. 0 the module is not affected during wait mode 1 the module ceases to be clocked during wait mode 4 synch synchronized status this read-only ?g indicates whether the mscan is synchronized to the can bus and able to participate in the communication process. it is set and cleared by the mscan. 0 mscan is not synchronized to the can bus 1 mscan is synchronized to the can bus 3 time timer enable this bit activates an internal 16-bit wide free running timer which is clocked by the bit clock rate. if the timer is enabled, a 16-bit time stamp will be assigned to each transmitted/received message within the active tx/rx buffer. right after the eof of a valid message on the can bus, the time stamp is written to the highest bytes (0x000e, 0x000f) in the appropriate buffer (see section 18.3.3, ?rogrammers model of message storage ?. the internal timer is reset (all bits set to 0) when disabled. this bit is held low in initialization mode. 0 disable internal mscan timer 1 enable internal mscan timer
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 592 freescale semiconductor 18.3.2.2 mscan control register 1 (canctl1) the canctl1 register provides various control bits and handshake status information of the mscan module as described below. 2 wupe 3 wake-up enable ?this con?uration bit allows the mscan to restart from sleep mode or from power down mode (entered from sleep) when traf? on can is detected (see section 18.4.5.5, ?scan sleep mode ?. this bit must be con?ured before sleep mode entry for the selected function to take effect. 0 wake-up disabled ?the mscan ignores traf? on can 1 wake-up enabled ?the mscan is able to restart 1 slprq 4 sleep mode request ?this bit requests the mscan to enter sleep mode, which is an internal power saving mode (see section 18.4.5.5, ?scan sleep mode ?. the sleep mode request is serviced when the can bus is idle, i.e., the module is not receiving a message and all transmit buffers are empty. the module indicates entry to sleep mode by setting slpak = 1 (see section 18.3.2.2, ?scan control register 1 (canctl1) ?. slprq cannot be set while the wupif ?g is set (see section 18.3.2.5, ?scan receiver flag register (canrflg) ?. sleep mode will be active until slprq is cleared by the cpu or, depending on the setting of wupe, the mscan detects activity on the can bus and clears slprq itself. 0 running ?the mscan functions normally 1 sleep mode request ?the mscan enters sleep mode when can bus idle 0 initrq 5,6 initialization mode request ?when this bit is set by the cpu, the mscan skips to initialization mode (see section 18.4.4.5, ?scan initialization mode ?. any ongoing transmission or reception is aborted and synchronization to the can bus is lost. the module indicates entry to initialization mode by setting initak = 1 ( section 18.3.2.2, ?scan control register 1 (canctl1) ?. the following registers enter their hard reset state and restore their default values: canctl0 7 , canrflg 8 , canrier 9 , cantflg, cantier, cantarq, cantaak, and cantbsel. the registers canctl1, canbtr0, canbtr1, canidac, canidar0-7, and canidmr0-7 can only be written by the cpu when the mscan is in initialization mode (initrq = 1 and initak = 1). the values of the error counters are not affected by initialization mode. when this bit is cleared by the cpu, the mscan restarts and then tries to synchronize to the can bus. if the mscan is not in bus-off state, it synchronizes after 11 consecutive recessive bits on the can bus; if the mscan is in bus-off state, it continues to wait for 128 occurrences of 11 consecutive recessive bits. writing to other bits in canctl0, canrflg, canrier, cantflg, or cantier must be done only after initialization mode is exited, which is initrq = 0 and initak = 0. 0 normal operation 1 mscan in initialization mode 1 see the bosch can 2.0a/b speci?ation for a detailed de?ition of transmitter and receiver states. 2 in order to protect from accidentally violating the can protocol, txcan is immediately forced to a recessive state when the cpu enters wait (cswai = 1) or stop mode (see section 18.4.5.2, ?peration in wait mode and section 18.4.5.3, ?peration in stop mode ? . 3 the cpu has to make sure that the wupe register and the wupie wake-up interrupt enable register (see section 18.3.2.6, ?scan receiver interrupt enable register (canrier) ) is enabled, if the recovery mechanism from stop or wait is required. 4 the cpu cannot clear slprq before the mscan has entered sleep mode (slprq = 1 and slpak = 1). 5 the cpu cannot clear initrq before the mscan has entered initialization mode (initrq = 1 and initak = 1). 6 in order to protect from accidentally violating the can protocol, txcan is immediately forced to a recessive state when the initialization mode is requested by the cpu. thus, the recommended procedure is to bring the mscan into sleep mode (slprq = 1 and slpak = 1) before requesting initialization mode. 7 not including wupe, initrq, and slprq. 8 tstat1 and tstat0 are not affected by initialization mode. 9 rstat1 and rstat0 are not affected by initialization mode. table 18-3. canctl0 register field descriptions (continued) field description
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 593 module base + 0x0001 access: user read/write 1 1 read: anytime write: anytime in initialization mode (initrq = 1 and initak = 1), except cane which is write once in normal and anytime in special system operation modes when the mscan is in initialization mode (initrq = 1 and initak = 1) 76543210 r cane clksrc loopb listen borm wupm slpak initak w reset: 00010001 = unimplemented figure 18-5. mscan control register 1 (canctl1) table 18-4. canctl1 register field descriptions field description 7 cane mscan enable 0 mscan module is disabled 1 mscan module is enabled 6 clksrc mscan clock source this bit de?es the clock source for the mscan module (only for systems with a clock generation module; section 18.4.3.2, ?lock system , and section figure 18-43., ?scan clocking scheme ,?. 0 mscan clock source is the oscillator clock 1 mscan clock source is the bus clock 5 loopb loopback self test mode when this bit is set, the mscan performs an internal loopback which can be used for self test operation. the bit stream output of the transmitter is fed back to the receiver internally. the rxcan input is ignored and the txcan output goes to the recessive state (logic 1). the mscan behaves as it does normally when transmitting and treats its own transmitted message as a message received from a remote node. in this state, the mscan ignores the bit sent during the ack slot in the can frame acknowledge ?ld to ensure proper reception of its own message. both transmit and receive interrupts are generated. 0 loopback self test disabled 1 loopback self test enabled 4 listen listen only mode this bit con?ures the mscan as a can bus monitor. when listen is set, all valid can messages with matching id are received, but no acknowledgement or error frames are sent out (see section 18.4.4.4, ?isten-only mode ?. in addition, the error counters are frozen. listen only mode supports applications which require ?ot plugging?or throughput analysis. the mscan is unable to transmit any messages when listen only mode is active. 0 normal operation 1 listen only mode activated 3 borm bus-off recovery mode ?this bit con?ures the bus-off state recovery mode of the mscan. refer to section 18.5.2, ?us-off recovery , for details. 0 automatic bus-off recovery (see bosch can 2.0a/b protocol speci?ation) 1 bus-off recovery upon user request 2 wupm wake-up mode ?if wupe in canctl0 is enabled, this bit de?es whether the integrated low-pass ?ter is applied to protect the mscan from spurious wake-up (see section 18.4.5.5, ?scan sleep mode ?. 0 mscan wakes up on any dominant level on the can bus 1 mscan wakes up only in case of a dominant pulse on the can bus that has a length of t wup
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 594 freescale semiconductor 18.3.2.3 mscan bus timing register 0 (canbtr0) the canbtr0 register con?ures various can bus timing parameters of the mscan module. 1 slpak sleep mode acknowledge ?this ?g indicates whether the mscan module has entered sleep mode (see section 18.4.5.5, ?scan sleep mode ?. it is used as a handshake ?g for the slprq sleep mode request. sleep mode is active when slprq = 1 and slpak = 1. depending on the setting of wupe, the mscan will clear the ?g if it detects activity on the can bus while in sleep mode. 0 running ?the mscan operates normally 1 sleep mode active ?the mscan has entered sleep mode 0 initak initialization mode acknowledge ?this ?g indicates whether the mscan module is in initialization mode (see section 18.4.4.5, ?scan initialization mode ?. it is used as a handshake ?g for the initrq initialization mode request. initialization mode is active when initrq = 1 and initak = 1. the registers canctl1, canbtr0, canbtr1, canidac, canidar0?anidar7, and canidmr0?anidmr7 can be written only by the cpu when the mscan is in initialization mode. 0 running ?the mscan operates normally 1 initialization mode active ?the mscan has entered initialization mode module base + 0x0002 access: user read/write 1 1 read: anytime write: anytime in initialization mode (initrq = 1 and initak = 1) 76543210 r sjw1 sjw0 brp5 brp4 brp3 brp2 brp1 brp0 w reset: 00000000 figure 18-6. mscan bus timing register 0 (canbtr 0 ) table 18-5. canbtr 0 register field descriptions field description 7-6 sjw[1:0] synchronization jump width the synchronization jump width de?es the maximum number of time quanta (tq) clock cycles a bit can be shortened or lengthened to achieve resynchronization to data transitions on the can bus (see table 18-6 ). 5-0 brp[5:0] baud rate prescaler these bits determine the time quanta (tq) clock which is used to build up the bit timing (see table 18-7 ). table 18-6. synchronization jump width sjw1 sjw0 synchronization jump width 0 0 1 tq clock cycle 0 1 2 tq clock cycles 1 0 3 tq clock cycles 1 1 4 tq clock cycles table 18-4. canctl1 register field descriptions (continued) field description
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 595 18.3.2.4 mscan bus timing register 1 (canbtr1) the canbtr1 register con?ures various can bus timing parameters of the mscan module. table 18-7. baud rate prescaler brp5 brp4 brp3 brp2 brp1 brp0 prescaler value (p) 000000 1 000001 2 000010 3 000011 4 :::::: : 111111 64 module base + 0x0003 access: user read/write 1 1 read: anytime write: anytime in initialization mode (initrq = 1 and initak = 1) 76543210 r samp tseg22 tseg21 tseg20 tseg13 tseg12 tseg11 tseg10 w reset: 00000000 figure 18-7. mscan bus timing register 1 (canbtr1) table 18-8. canbtr1 register field descriptions field description 7 samp sampling ?this bit determines the number of can bus samples taken per bit time. 0 one sample per bit. 1 three samples per bit 1 . if samp = 0, the resulting bit value is equal to the value of the single bit positioned at the sample point. if samp = 1, the resulting bit value is determined by using majority rule on the three total samples. for higher bit rates, it is recommended that only one sample is taken per bit time (samp = 0). 1 in this case, phase_seg1 must be at least 2 time quanta (tq). 6-4 tseg2[2:0] time segment 2 time segments within the bit time ? the number of clock cycles per bit time and the location of the sample point (see figure 18-44 ). time segment 2 (tseg2) values are programmable as shown in table 18-9 . 3-0 tseg1[3:0] time segment 1 time segments within the bit time ? the number of clock cycles per bit time and the location of the sample point (see figure 18-44 ). time segment 1 (tseg1) values are programmable as shown in table 18-10 .
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 596 freescale semiconductor the bit time is determined by the oscillator frequency, the baud rate prescaler, and the number of time quanta (tq) clock cycles per bit (as shown in table 18-9 and table 18-10 ). eqn. 18-1 18.3.2.5 mscan receiver flag register (canrflg) a ?g can be cleared only by software (writing a 1 to the corresponding bit position) when the condition which caused the setting is no longer valid. every ?g has an associated interrupt enable bit in the canrier register. table 18-9. time segment 2 values tseg22 tseg21 tseg20 time segment 2 0 0 0 1 tq clock cycle 1 1 this setting is not valid. please refer to table 18-37 for valid settings. 0 0 1 2 tq clock cycles ::: : 1 1 0 7 tq clock cycles 1 1 1 8 tq clock cycles table 18-10. time segment 1 values tseg13 tseg12 tseg11 tseg10 time segment 1 0 0 0 0 1 tq clock cycle 1 1 this setting is not valid. please refer to table 18-37 for valid settings. 0 0 0 1 2 tq clock cycles 1 0 0 1 0 3 tq clock cycles 1 0 0 1 1 4 tq clock cycles :::: : 1 1 1 0 15 tq clock cycles 1 1 1 1 16 tq clock cycles module base + 0x0004 access: user read/write 1 76543210 r wupif cscif rstat1 rstat0 tstat1 tstat0 ovrif rxf w reset: 00000000 = unimplemented figure 18-8. mscan receiver flag register (canrflg) bit time prescaler value () f canclk ----------------------------------------------------- - 1 timesegment1 timesegment2 ++ () ? =
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 597 note the canrflg register is held in the reset state 1 when the initialization mode is active (initrq = 1 and initak = 1). this register is writable again as soon as the initialization mode is exited (initrq = 0 and initak = 0). 1 read: anytime write: anytime when not in initialization mode, except rstat[1:0] and tstat[1:0] ?gs which are read-only; write of 1 clears ?g; write of 0 is ignored 1. the rstat[1:0], tstat[1:0] bits are not affected by initialization mode. table 18-11. canrflg register field descriptions field description 7 wupif wake-up interrupt flag if the mscan detects can bus activity while in sleep mode (see section 18.4.5.5, ?scan sleep mode ,? and wupe = 1 in cantctl0 (see section 18.3.2.1, ?scan control register 0 (canctl0) ?, the module will set wupif. if not masked, a wake-up interrupt is pending while this ?g is set. 0 no wake-up activity observed while in sleep mode 1 mscan detected activity on the can bus and requested wake-up 6 cscif can status change interrupt flag ?this ?g is set when the mscan changes its current can bus status due to the actual value of the transmit error counter (tec) and the receive error counter (rec). an additional 4-bit (rstat[1:0], tstat[1:0]) status register, which is split into separate sections for tec/rec, informs the system on the actual can bus status (see section 18.3.2.6, ?scan receiver interrupt enable register (canrier) ?. if not masked, an error interrupt is pending while this ?g is set. cscif provides a blocking interrupt. that guarantees that the receiver/transmitter status bits (rstat/tstat) are only updated when no can status change interrupt is pending. if the tecs/recs change their current value after the cscif is asserted, which would cause an additional state change in the rstat/tstat bits, these bits keep their status until the current cscif interrupt is cleared again. 0 no change in can bus status occurred since last interrupt 1 mscan changed current can bus status 5-4 rstat[1:0] receiver status bits the values of the error counters control the actual can bus status of the mscan. as soon as the status change interrupt ?g (cscif) is set, these bits indicate the appropriate receiver related can bus status of the mscan. the coding for the bits rstat1, rstat0 is: 00 rxok: 0 receive error counter 96 01 rxwrn: 96 < receive error counter 127 10 rxerr: 127 < receive error counter 11 bus-off 1 : transmit error counter > 255 3-2 tstat[1:0] transmitter status bits the values of the error counters control the actual can bus status of the mscan. as soon as the status change interrupt ?g (cscif) is set, these bits indicate the appropriate transmitter related can bus status of the mscan. the coding for the bits tstat1, tstat0 is: 00 txok: 0 transmit error counter 96 01 txwrn: 96 < transmit error counter 127 10 txerr: 127 < transmit error counter 255 11 bus-off: transmit error counter > 255
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 598 freescale semiconductor 18.3.2.6 mscan receiver interrupt enable register (canrier) this register contains the interrupt enable bits for the interrupt ?gs described in the canrflg register. note the canrier register is held in the reset state when the initialization mode is active (initrq=1 and initak=1). this register is writable when not in initialization mode (initrq=0 and initak=0). the rstate[1:0], tstate[1:0] bits are not affected by initialization mode. 1 ovrif overrun interrupt flag this ?g is set when a data overrun condition occurs. if not masked, an error interrupt is pending while this ?g is set. 0 no data overrun condition 1 a data overrun detected 0 rxf 2 receive buffer full flag ?rxf is set by the mscan when a new message is shifted in the receiver fifo. this ?g indicates whether the shifted buffer is loaded with a correctly received message (matching identi?r, matching cyclic redundancy code (crc) and no other errors detected). after the cpu has read that message from the rxfg buffer in the receiver fifo, the rxf ?g must be cleared to release the buffer. a set rxf ?g prohibits the shifting of the next fifo entry into the foreground buffer (rxfg). if not masked, a receive interrupt is pending while this ?g is set. 0 no new message available within the rxfg 1 the receiver fifo is not empty. a new message is available in the rxfg 1 redundant information for the most critical can bus status which is ?us-off? this only occurs if the tx error counter exceeds a number of 255 errors. bus-off affects the receiver state. as soon as the transmitter leaves its bus-off state the receiver state skips to rxok too. refer also to tstat[1:0] coding in this register. 2 to ensure data integrity, do not read the receive buffer registers while the rxf ?g is cleared. for mcus with dual cpus, reading the receive buffer registers while the rxf ?g is cleared may result in a cpu fault condition. module base + 0x0005 access: user read/write 1 1 read: anytime write: anytime when not in initialization mode 76543210 r wupie cscie rstate1 rstate0 tstate1 tstate0 ovrie rxfie w reset: 00000000 figure 18-9. mscan receiver interrupt enable register (canrier) table 18-11. canrflg register field descriptions (continued) field description
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 599 18.3.2.7 mscan transmitter flag register (cantflg) the transmit buffer empty ?gs each have an associated interrupt enable bit in the cantier register. table 18-12. canrier register field descriptions field description 7 wupie 1 1 wupie and wupe (see section 18.3.2.1, ?scan control register 0 (canctl0) ? must both be enabled if the recovery mechanism from stop or wait is required. wake-up interrupt enable 0 no interrupt request is generated from this event. 1 a wake-up event causes a wake-up interrupt request. 6 cscie can status change interrupt enable 0 no interrupt request is generated from this event. 1 a can status change event causes an error interrupt request. 5-4 rstate[1:0] receiver status change enable these rstat enable bits control the sensitivity level in which receiver state changes are causing cscif interrupts. independent of the chosen sensitivity level the rstat ?gs continue to indicate the actual receiver state and are only updated if no cscif interrupt is pending. 00 do not generate any cscif interrupt caused by receiver state changes. 01 generate cscif interrupt only if the receiver enters or leaves ?us-off?state. discard other receiver state changes for generating cscif interrupt. 10 generate cscif interrupt only if the receiver enters or leaves ?xerr?or ?us-off 2 state. discard other receiver state changes for generating cscif interrupt. 11 generate cscif interrupt on all state changes. 2 bus-off state is only de?ed for transmitters by the can standard (see bosch can 2.0a/b protocol speci?ation). because the only possible state change for the transmitter from bus-off to txok also forces the receiver to skip its current state to rxok, the coding of the rxstat[1:0] ?gs de?e an additional bus-off state for the receiver (see section 18.3.2.5, ?scan receiver flag register (canrflg) ?. 3-2 tstate[1:0] transmitter status change enable these tstat enable bits control the sensitivity level in which transmitter state changes are causing cscif interrupts. independent of the chosen sensitivity level, the tstat ?gs continue to indicate the actual transmitter state and are only updated if no cscif interrupt is pending. 00 do not generate any cscif interrupt caused by transmitter state changes. 01 generate cscif interrupt only if the transmitter enters or leaves ?us-off?state. discard other transmitter state changes for generating cscif interrupt. 10 generate cscif interrupt only if the transmitter enters or leaves ?xerr?or ?us-off?state. discard other transmitter state changes for generating cscif interrupt. 11 generate cscif interrupt on all state changes. 1 ovrie overrun interrupt enable 0 no interrupt request is generated from this event. 1 an overrun event causes an error interrupt request. 0 rxfie receiver full interrupt enable 0 no interrupt request is generated from this event. 1 a receive buffer full (successful message reception) event causes a receiver interrupt request.
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 600 freescale semiconductor note the cantflg register is held in the reset state when the initialization mode is active (initrq = 1 and initak = 1). this register is writable when not in initialization mode (initrq = 0 and initak = 0). 18.3.2.8 mscan transmitter interrupt enable register (cantier) this register contains the interrupt enable bits for the transmit buffer empty interrupt ?gs. module base + 0x0006 access: user read/write 1 1 read: anytime write: anytime when not in initialization mode; write of 1 clears ?g, write of 0 is ignored 76543210 r0 0 0 00 txe2 txe1 txe0 w reset: 00000111 = unimplemented figure 18-10. mscan transmitter flag register (cantflg) table 18-13. cantflg register field descriptions field description 2-0 txe[2:0] transmitter buffer empty this ?g indicates that the associated transmit message buffer is empty, and thus not scheduled for transmission. the cpu must clear the ?g after a message is set up in the transmit buffer and is due for transmission. the mscan sets the ?g after the message is sent successfully. the ?g is also set by the mscan when the transmission request is successfully aborted due to a pending abort request (see section 18.3.2.9, ?scan transmitter message abort request register (cantarq) ?. if not masked, a transmit interrupt is pending while this ?g is set. clearing a txex ?g also clears the corresponding abtakx (see section 18.3.2.10, ?scan transmitter message abort acknowledge register (cantaak) ?. when a txex ?g is set, the corresponding abtrqx bit is cleared (see section 18.3.2.9, ?scan transmitter message abort request register (cantarq) ?. when listen-mode is active (see section 18.3.2.2, ?scan control register 1 (canctl1) ? the txex ?gs cannot be cleared and no transmission is started. read and write accesses to the transmit buffer will be blocked, if the corresponding txex bit is cleared (txex = 0) and the buffer is scheduled for transmission. 0 the associated message buffer is full (loaded with a message due for transmission) 1 the associated message buffer is empty (not scheduled) module base + 0x0007 access: user read/write 1 76543210 r00000 txeie2 txeie1 txeie0 w reset: 00000000 = unimplemented figure 18-11. mscan transmitter interrupt enable register (cantier)
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 601 note the cantier register is held in the reset state when the initialization mode is active (initrq = 1 and initak = 1). this register is writable when not in initialization mode (initrq = 0 and initak = 0). 18.3.2.9 mscan transmitter message abort request register (cantarq) the cantarq register allows abort request of queued messages as described below. note the cantarq register is held in the reset state when the initialization mode is active (initrq = 1 and initak = 1). this register is writable when not in initialization mode (initrq = 0 and initak = 0). 1 read: anytime write: anytime when not in initialization mode table 18-14. cantier register field descriptions field description 2-0 txeie[2:0] transmitter empty interrupt enable 0 no interrupt request is generated from this event. 1 a transmitter empty (transmit buffer available for transmission) event causes a transmitter empty interrupt request. module base + 0x0008 access: user read/write 1 1 read: anytime write: anytime when not in initialization mode 76543210 r00000 abtrq2 abtrq1 abtrq0 w reset: 00000000 = unimplemented figure 18-12. mscan transmitter message abort request register (cantarq) table 18-15. cantarq register field descriptions field description 2-0 abtrq[2:0] abort request ?the cpu sets the abtrqx bit to request that a scheduled message buffer (txex = 0) be aborted. the mscan grants the request if the message has not already started transmission, or if the transmission is not successful (lost arbitration or error). when a message is aborted, the associated txe (see section 18.3.2.7, ?scan transmitter flag register (cantflg) ? and abort acknowledge ?gs (abtak, see section 18.3.2.10, ?scan transmitter message abort acknowledge register (cantaak) ? are set and a transmit interrupt occurs if enabled. the cpu cannot reset abtrqx. abtrqx is reset whenever the associated txe ?g is set. 0 no abort request 1 abort request pending
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 602 freescale semiconductor 18.3.2.10 mscan transmitter message abort acknowledge register (cantaak) the cantaak register indicates the successful abort of a queued message, if requested by the appropriate bits in the cantarq register. note the cantaak register is held in the reset state when the initialization mode is active (initrq = 1 and initak = 1). 18.3.2.11 mscan transmit buffer selection register (cantbsel) the cantbsel register allows the selection of the actual transmit message buffer, which then will be accessible in the cantxfg register space. module base + 0x0009 access: user read/write 1 1 read: anytime write: unimplemented 76543210 r00000 abtak2 abtak1 abtak0 w reset: 00000000 = unimplemented figure 18-13. mscan transmitter message abort acknowledge register (cantaak) table 18-16. cantaak register field descriptions field description 2-0 abtak[2:0] abort acknowledge ?this ?g acknowledges that a message was aborted due to a pending abort request from the cpu. after a particular message buffer is ?gged empty, this ?g can be used by the application software to identify whether the message was aborted successfully or was sent anyway. the abtakx ?g is cleared whenever the corresponding txe ?g is cleared. 0 the message was not aborted. 1 the message was aborted. module base + 0x000a access: user read/write 1 1 read: find the lowest ordered bit set to 1, all other bits will be read as 0 write: anytime when not in initialization mode 76543210 r00000 tx2 tx1 tx0 w reset: 00000000 = unimplemented figure 18-14. mscan transmit buffer selection register (cantbsel)
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 603 note the cantbsel register is held in the reset state when the initialization mode is active (initrq = 1 and initak=1). this register is writable when not in initialization mode (initrq = 0 and initak = 0). the following gives a short programming example of the usage of the cantbsel register: to get the next available transmit buffer, application software must read the cantflg register and write this value back into the cantbsel register. in this example tx buffers tx1 and tx2 are available. the value read from cantflg is therefore 0b0000_0110. when writing this value back to cantbsel, the tx buffer tx1 is selected in the cantxfg because the lowest numbered bit set to 1 is at bit position 1. reading back this value out of cantbsel results in 0b0000_0010, because only the lowest numbered bit position set to 1 is presented. this mechanism eases the application softwares selection of the next available tx buffer. ldaa cantflg; value read is 0b0000_0110 staa cantbsel; value written is 0b0000_0110 ldaa cantbsel; value read is 0b0000_0010 if all transmit message buffers are deselected, no accesses are allowed to the cantxfg registers. 18.3.2.12 mscan identi?r acceptance control register (canidac) the canidac register is used for identi?r acceptance control as described below. table 18-17. cantbsel register field descriptions field description 2-0 tx[2:0] transmit buffer select ?the lowest numbered bit places the respective transmit buffer in the cantxfg register space (e.g., tx1 = 1 and tx0 = 1 selects transmit buffer tx0; tx1 = 1 and tx0 = 0 selects transmit buffer tx1). read and write accesses to the selected transmit buffer will be blocked, if the corresponding txex bit is cleared and the buffer is scheduled for transmission (see section 18.3.2.7, ?scan transmitter flag register (cantflg) ?. 0 the associated message buffer is deselected 1 the associated message buffer is selected, if lowest numbered bit module base + 0x000b access: user read/write 1 1 read: anytime write: anytime in initialization mode (initrq = 1 and initak = 1), except bits idhitx, which are read-only 76543210 r0 0 idam1 idam0 0 idhit2 idhit1 idhit0 w reset: 00000000 = unimplemented figure 18-15. mscan identi?r acceptance control register (canidac)
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 604 freescale semiconductor the idhitx indicators are always related to the message in the foreground buffer (rxfg). when a message gets shifted into the foreground buffer of the receiver fifo the indicators are updated as well. 18.3.2.13 mscan reserved register this register is reserved for factory testing of the mscan module and is not available in normal system operating modes. table 18-18. canidac register field descriptions field description 5-4 idam[1:0] identi?r acceptance mode the cpu sets these ?gs to de?e the identi?r acceptance ?ter organization (see section 18.4.3, ?denti?r acceptance filter ?. table 18-19 summarizes the different settings. in ?ter closed mode, no message is accepted such that the foreground buffer is never reloaded. 2-0 idhit[2:0] identi?r acceptance hit indicator ?the mscan sets these ?gs to indicate an identi?r acceptance hit (see section 18.4.3, ?denti?r acceptance filter ?. table 18-20 summarizes the different settings. table 18-19. identi?r acceptance mode settings idam1 idam0 identi?r acceptance mode 0 0 two 32-bit acceptance ?ters 0 1 four 16-bit acceptance ?ters 1 0 eight 8-bit acceptance ?ters 1 1 filter closed table 18-20. identi?r acceptance hit indication idhit2 idhit1 idhit0 identi?r acceptance hit 0 0 0 filter 0 hit 0 0 1 filter 1 hit 0 1 0 filter 2 hit 0 1 1 filter 3 hit 1 0 0 filter 4 hit 1 0 1 filter 5 hit 1 1 0 filter 6 hit 1 1 1 filter 7 hit module base + 0x000c to module base + 0x000d access: user read/write 1 76543210 r00000000 w reset: 00000000 = unimplemented figure 18-16. mscan reserved register
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 605 note writing to this register when in special system operating modes can alter the mscan functionality. 18.3.2.14 mscan miscellaneous register (canmisc) this register provides additional features. 18.3.2.15 mscan receive error counter (canrxerr) this register re?cts the status of the mscan receive error counter. 1 read: always reads zero in normal system operation modes write: unimplemented in normal system operation modes module base + 0x000d access: user read/write 1 1 read: anytime write: anytime; write of ??clears ?g; write of ??ignored 76543210 r0000000 bohold w reset: 00000000 = unimplemented figure 18-17. mscan miscellaneous register (canmisc) table 18-21. canmisc register field descriptions field description 0 bohold bus-off state hold until user request ?if borm is set in mscan control register 1 (canctl1), this bit indicates whether the module has entered the bus-off state. clearing this bit requests the recovery from bus-off. refer to section 18.5.2, ?us-off recovery , for details. 0 module is not bus-off or recovery has been requested by user in bus-off state 1 module is bus-off and holds this state until user request module base + 0x000e access: user read/write 1 1 read: only when in sleep mode (slprq = 1 and slpak = 1) or initialization mode (initrq = 1 and initak = 1) write: unimplemented 76543210 r rxerr7 rxerr6 rxerr5 rxerr4 rxerr3 rxerr2 rxerr1 rxerr0 w reset: 00000000 = unimplemented figure 18-18. mscan receive error counter (canrxerr)
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 606 freescale semiconductor note reading this register when in any other mode other than sleep or initialization mode may return an incorrect value. for mcus with dual cpus, this may result in a cpu fault condition. writing to this register when in special modes can alter the mscan functionality. 18.3.2.16 mscan transmit error counter (cantxerr) this register re?cts the status of the mscan transmit error counter. note reading this register when in any other mode other than sleep or initialization mode, may return an incorrect value. for mcus with dual cpus, this may result in a cpu fault condition. writing to this register when in special modes can alter the mscan functionality. 18.3.2.17 mscan identi?r acceptance registers (canidar0-7) on reception, each message is written into the background receive buffer. the cpu is only signalled to read the message if it passes the criteria in the identi?r acceptance and identi?r mask registers (accepted); otherwise, the message is overwritten by the next message (dropped). the acceptance registers of the mscan are applied on the idr0?dr3 registers (see section 18.3.3.1, ?denti?r registers (idr0?dr3) ? of incoming messages in a bit by bit manner (see section 18.4.3, ?denti?r acceptance filter ?. for extended identi?rs, all four acceptance and mask registers are applied. for standard identi?rs, only the ?st two (canidar0/1, canidmr0/1) are applied. module base + 0x000f access: user read/write 1 1 read: only when in sleep mode (slprq = 1 and slpak = 1) or initialization mode (initrq = 1 and initak = 1) write: unimplemented 76543210 r txerr7 txerr6 txerr5 txerr4 txerr3 txerr2 txerr1 txerr0 w reset: 00000000 = unimplemented figure 18-19. mscan transmit error counter (cantxerr)
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 607 18.3.2.18 mscan identi?r mask registers (canidmr0?anidmr7) the identi?r mask register speci?s which of the corresponding bits in the identi?r acceptance register are relevant for acceptance ?tering. to receive standard identi?rs in 32 bit ?ter mode, it is required to program the last three bits (am[2:0]) in the mask registers canidmr1 and canidmr5 to ?ont care. to receive standard identi?rs in 16 bit ?ter mode, it is required to program the last three bits (am[2:0]) in the mask registers canidmr1, canidmr3, canidmr5, and canidmr7 to ?ont care. module base + 0x0010 to module base + 0x0013 access: user read/write 1 1 read: anytime write: anytime in initialization mode (initrq = 1 and initak = 1) 76543210 r ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 w reset 00000000 figure 18-20. mscan identi?r acceptance registers (first bank) ?canidar0?anidar3 table 18-22. canidar0?anidar3 register field descriptions field description 7-0 ac[7:0] acceptance code bits ac[7:0] comprise a user-de?ed sequence of bits with which the corresponding bits of the related identi?r register (idrn) of the receive message buffer are compared. the result of this comparison is then masked with the corresponding identi?r mask register. module base + 0x0018 to module base + 0x001b access: user read/write 1 1 read: anytime write: anytime in initialization mode (initrq = 1 and initak = 1) 76543210 r ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 w reset 00000000 figure 18-21. mscan identi?r acceptance registers (second bank) ?canidar4?anidar7 table 18-23. canidar4?anidar7 register field descriptions field description 7-0 ac[7:0] acceptance code bits ac[7:0] comprise a user-de?ed sequence of bits with which the corresponding bits of the related identi?r register (idrn) of the receive message buffer are compared. the result of this comparison is then masked with the corresponding identi?r mask register.
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 608 freescale semiconductor module base + 0x0014 to module base + 0x0017 access: user read/write 1 1 read: anytime write: anytime in initialization mode (initrq = 1 and initak = 1) 76543210 r am7 am6 am5 am4 am3 am2 am1 am0 w reset 00000000 figure 18-22. mscan identi?r mask registers (first bank) ?canidmr0?anidmr3 table 18-24. canidmr0?anidmr3 register field descriptions field description 7-0 am[7:0] acceptance mask bits if a particular bit in this register is cleared, this indicates that the corresponding bit in the identi?r acceptance register must be the same as its identi?r bit before a match is detected. the message is accepted if all such bits match. if a bit is set, it indicates that the state of the corresponding bit in the identi?r acceptance register does not affect whether or not the message is accepted. 0 match corresponding acceptance code register and identi?r bits 1 ignore corresponding acceptance code register bit module base + 0x001c to module base + 0x001f access: user read/write 1 1 read: anytime write: anytime in initialization mode (initrq = 1 and initak = 1) 76543210 r am7 am6 am5 am4 am3 am2 am1 am0 w reset 00000000 figure 18-23. mscan identi?r mask registers (second bank) ?canidmr4?anidmr7 table 18-25. canidmr4?anidmr7 register field descriptions field description 7-0 am[7:0] acceptance mask bits if a particular bit in this register is cleared, this indicates that the corresponding bit in the identi?r acceptance register must be the same as its identi?r bit before a match is detected. the message is accepted if all such bits match. if a bit is set, it indicates that the state of the corresponding bit in the identi?r acceptance register does not affect whether or not the message is accepted. 0 match corresponding acceptance code register and identi?r bits 1 ignore corresponding acceptance code register bit
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 609 18.3.3 programmers model of message storage the following section details the organization of the receive and transmit message buffers and the associated control registers. to simplify the programmer interface, the receive and transmit message buffers have the same outline. each message buffer allocates 16 bytes in the memory map containing a 13 byte data structure. an additional transmit buffer priority register (tbpr) is de?ed for the transmit buffers. within the last two bytes of this memory map, the mscan stores a special 16-bit time stamp, which is sampled from an internal timer after successful transmission or reception of a message. this feature is only available for transmit and receiver buffers, if the time bit is set (see section 18.3.2.1, ?scan control register 0 (canctl0) ?. the time stamp register is written by the mscan. the cpu can only read these registers. figure 18-24 shows the common 13-byte data structure of receive and transmit buffers for extended identi?rs. the mapping of standard identi?rs into the idr registers is shown in figure 18-25 . all bits of the receive and transmit buffers are ??out of reset because of ram-based implementation 1 . all reserved or unused bits of the receive and transmit buffers always read ?? table 18-26. message buffer organization offset address register access 0x00x0 identi?r register 0 r/w 0x00x1 identi?r register 1 r/w 0x00x2 identi?r register 2 r/w 0x00x3 identi?r register 3 r/w 0x00x4 data segment register 0 r/w 0x00x5 data segment register 1 r/w 0x00x6 data segment register 2 r/w 0x00x7 data segment register 3 r/w 0x00x8 data segment register 4 r/w 0x00x9 data segment register 5 r/w 0x00xa data segment register 6 r/w 0x00xb data segment register 7 r/w 0x00xc data length register r/w 0x00xd transmit buffer priority register 1 1 not applicable for receive buffers r/w 0x00xe time stamp register (high byte) r 0x00xf time stamp register (low byte) r 1. exception: the transmit buffer priority registers are 0 out of reset.
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 610 freescale semiconductor figure 18-24. receive/transmit message buffer ?extended identi?r mapping register name bit 7 654321 bit0 0x00x0 idr0 r id28 id27 id26 id25 id24 id23 id22 id21 w 0x00x1 idr1 r id20 id19 id18 srr (=1) ide (=1) id17 id16 id15 w 0x00x2 idr2 r id14 id13 id12 id11 id10 id9 id8 id7 w 0x00x3 idr3 r id6 id5 id4 id3 id2 id1 id0 rtr w 0x00x4 dsr0 r db7 db6 db5 db4 db3 db2 db1 db0 w 0x00x5 dsr1 r db7 db6 db5 db4 db3 db2 db1 db0 w 0x00x6 dsr2 r db7 db6 db5 db4 db3 db2 db1 db0 w 0x00x7 dsr3 r db7 db6 db5 db4 db3 db2 db1 db0 w 0x00x8 dsr4 r db7 db6 db5 db4 db3 db2 db1 db0 w 0x00x9 dsr5 r db7 db6 db5 db4 db3 db2 db1 db0 w 0x00xa dsr6 r db7 db6 db5 db4 db3 db2 db1 db0 w 0x00xb dsr7 r db7 db6 db5 db4 db3 db2 db1 db0 w 0x00xc dlr r dlc3 dlc2 dlc1 dlc0 w
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 611 read: for transmit buffers, anytime when txex ?g is set (see section 18.3.2.7, ?scan transmitter flag register (cantflg) ? and the corresponding transmit buffer is selected in cantbsel (see section 18.3.2.11, ?scan transmit buffer selection register (cantbsel) ?. for receive buffers, only when rxf ?g is set (see section 18.3.2.5, ?scan receiver flag register (canrflg) ?. write: for transmit buffers, anytime when txex ?g is set (see section 18.3.2.7, ?scan transmitter flag register (cantflg) ? and the corresponding transmit buffer is selected in cantbsel (see section 18.3.2.11, ?scan transmit buffer selection register (cantbsel) ?. unimplemented for receive buffers. reset: unde?ed because of ram-based implementation 18.3.3.1 identi?r registers (idr0?dr3) the identi?r registers for an extended format identi?r consist of a total of 32 bits: id[28:0], srr, ide, and rtr. the identi?r registers for a standard format identi?r consist of a total of 13 bits: id[10:0], rtr, and ide. = unused, always read ? figure 18-25. receive/transmit message buffer ?standard identi?r mapping register name bit 7 654321 bit 0 idr0 0x00x0 r id10 id9 id8 id7 id6 id5 id4 id3 w idr1 0x00x1 r id2 id1 id0 rtr ide (=0) w idr2 0x00x2 r w idr3 0x00x3 r w = unused, always read ? figure 18-24. receive/transmit message buffer ?extended identi?r mapping (continued) register name bit 7 654321 bit0
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 612 freescale semiconductor 18.3.3.1.1 idr0?dr3 for extended identi?r mapping module base + 0x00x0 76543210 r id28 id27 id26 id25 id24 id23 id22 id21 w reset: xxxxxxxx figure 18-26. identi?r register 0 (idr0) ?extended identi?r mapping table 18-27. idr0 register field descriptions ?extended field description 7-0 id[28:21] extended format identi?r ?the identi?rs consist of 29 bits (id[28:0]) for the extended format. id28 is the most signi?ant bit and is transmitted ?st on the can bus during the arbitration procedure. the priority of an identi?r is de?ed to be highest for the smallest binary number. module base + 0x00x1 76543210 r id20 id19 id18 srr (=1) ide (=1) id17 id16 id15 w reset: xxxxxxxx figure 18-27. identi?r register 1 (idr1) ?extended identi?r mapping table 18-28. idr1 register field descriptions ?extended field description 7-5 id[20:18] extended format identi?r the identi?rs consist of 29 bits (id[28:0]) for the extended format. id28 is the most signi?ant bit and is transmitted ?st on the can bus during the arbitration procedure. the priority of an identi?r is de?ed to be highest for the smallest binary number. 4 srr substitute remote request ?this ?ed recessive bit is used only in extended format. it must be set to 1 by the user for transmission buffers and is stored as received on the can bus for receive buffers. 3 ide id extended this ?g indicates whether the extended or standard identi?r format is applied in this buffer. in the case of a receive buffer, the ?g is set as received and indicates to the cpu how to process the buffer identi?r registers. in the case of a transmit buffer, the ?g indicates to the mscan what type of identi?r to send. 0 standard format (11 bit) 1 extended format (29 bit) 2-0 id[17:15] extended format identi?r the identi?rs consist of 29 bits (id[28:0]) for the extended format. id28 is the most signi?ant bit and is transmitted ?st on the can bus during the arbitration procedure. the priority of an identi?r is de?ed to be highest for the smallest binary number.
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 613 module base + 0x00x2 76543210 r id14 id13 id12 id11 id10 id9 id8 id7 w reset: xxxxxxxx figure 18-28. identi?r register 2 (idr2) ?extended identi?r mapping table 18-29. idr2 register field descriptions ?extended field description 7-0 id[14:7] extended format identi?r the identi?rs consist of 29 bits (id[28:0]) for the extended format. id28 is the most signi?ant bit and is transmitted ?st on the can bus during the arbitration procedure. the priority of an identi?r is de?ed to be highest for the smallest binary number. module base + 0x00x3 76543210 r id6 id5 id4 id3 id2 id1 id0 rtr w reset: xxxxxxxx figure 18-29. identi?r register 3 (idr3) ?extended identi?r mapping table 18-30. idr3 register field descriptions ?extended field description 7-1 id[6:0] extended format identi?r the identi?rs consist of 29 bits (id[28:0]) for the extended format. id28 is the most signi?ant bit and is transmitted ?st on the can bus during the arbitration procedure. the priority of an identi?r is de?ed to be highest for the smallest binary number. 0 rtr remote transmission request ?this ?g re?cts the status of the remote transmission request bit in the can frame. in the case of a receive buffer, it indicates the status of the received frame and supports the transmission of an answering frame in software. in the case of a transmit buffer, this ?g de?es the setting of the rtr bit to be sent. 0 data frame 1 remote frame
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 614 freescale semiconductor 18.3.3.1.2 idr0?dr3 for standard identi?r mapping module base + 0x00x0 76543210 r id10 id9 id8 id7 id6 id5 id4 id3 w reset: xxxxxxxx figure 18-30. identi?r register 0 ?standard mapping table 18-31. idr0 register field descriptions ?standard field description 7-0 id[10:3] standard format identi?r the identi?rs consist of 11 bits (id[10:0]) for the standard format. id10 is the most signi?ant bit and is transmitted ?st on the can bus during the arbitration procedure. the priority of an identi?r is de?ed to be highest for the smallest binary number. see also id bits in table 18-32 . module base + 0x00x1 76543210 r id2 id1 id0 rtr ide (=0) w reset: xxxxxxxx = unused; always read ? figure 18-31. identi?r register 1 ?standard mapping table 18-32. idr1 register field descriptions field description 7-5 id[2:0] standard format identi?r the identi?rs consist of 11 bits (id[10:0]) for the standard format. id10 is the most signi?ant bit and is transmitted ?st on the can bus during the arbitration procedure. the priority of an identi?r is de?ed to be highest for the smallest binary number. see also id bits in table 18-31 . 4 rtr remote transmission request this ?g re?cts the status of the remote transmission request bit in the can frame. in the case of a receive buffer, it indicates the status of the received frame and supports the transmission of an answering frame in software. in the case of a transmit buffer, this ?g de?es the setting of the rtr bit to be sent. 0 data frame 1 remote frame 3 ide id extended this ?g indicates whether the extended or standard identi?r format is applied in this buffer. in the case of a receive buffer, the ?g is set as received and indicates to the cpu how to process the buffer identi?r registers. in the case of a transmit buffer, the ?g indicates to the mscan what type of identi?r to send. 0 standard format (11 bit) 1 extended format (29 bit)
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 615 18.3.3.2 data segment registers (dsr0-7) the eight data segment registers, each with bits db[7:0], contain the data to be transmitted or received. the number of bytes to be transmitted or received is determined by the data length code in the corresponding dlr register. 18.3.3.3 data length register (dlr) this register keeps the data length ?ld of the can frame. module base + 0x00x2 76543210 r w reset: xxxxxxxx = unused; always read ? figure 18-32. identi?r register 2 ?standard mapping module base + 0x00x3 76543210 r w reset: xxxxxxxx = unused; always read ? figure 18-33. identi?r register 3 ?standard mapping module base + 0x00x4 to module base + 0x00xb 76543210 r db7 db6 db5 db4 db3 db2 db1 db0 w reset: xxxxxxxx figure 18-34. data segment registers (dsr0?sr7) ?extended identi?r mapping table 18-33. dsr0?sr7 register field descriptions field description 7-0 db[7:0] data bits 7-0
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 616 freescale semiconductor 18.3.3.4 transmit buffer priority register (tbpr) this register de?es the local priority of the associated message buffer. the local priority is used for the internal prioritization process of the mscan and is de?ed to be highest for the smallest binary number. the mscan implements the following internal prioritization mechanisms: all transmission buffers with a cleared txex ?g participate in the prioritization immediately before the sof (start of frame) is sent. the transmission buffer with the lowest local priority ?ld wins the prioritization. in cases of more than one buffer having the same lowest priority, the message buffer with the lower index number wins. module base + 0x00xc 76543210 r dlc3 dlc2 dlc1 dlc0 w reset: xxxxxxxx = unused; always read ? figure 18-35. data length register (dlr) ?extended identi?r mapping table 18-34. dlr register field descriptions field description 3-0 dlc[3:0] data length code bits the data length code contains the number of bytes (data byte count) of the respective message. during the transmission of a remote frame, the data length code is transmitted as programmed while the number of transmitted data bytes is always 0. the data byte count ranges from 0 to 8 for a data frame. table 18-35 shows the effect of setting the dlc bits. table 18-35. data length codes data length code data byte count dlc3 dlc2 dlc1 dlc0 00000 00011 00102 00113 01004 01015 01106 01117 10008
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 617 18.3.3.5 time stamp register (tsrh?srl) if the time bit is enabled, the mscan will write a time stamp to the respective registers in the active transmit or receive buffer right after the eof of a valid message on the can bus (see section 18.3.2.1, ?scan control register 0 (canctl0) ?. in case of a transmission, the cpu can only read the time stamp after the respective transmit buffer has been ?gged empty. the timer value, which is used for stamping, is taken from a free running internal can bit clock. a timer overrun is not indicated by the mscan. the timer is reset (all bits set to 0) during initialization mode. the cpu can only read the time stamp registers. module base + 0x00xd access: user read/write 1 1 read: anytime when txex ?g is set (see section 18.3.2.7, ?scan transmitter flag register (cantflg) ? and the corresponding transmit buffer is selected in cantbsel (see section 18.3.2.11, ?scan transmit buffer selection register (cantbsel) ? write: anytime when txex ?g is set (see section 18.3.2.7, ?scan transmitter flag register (cantflg) ? and the corresponding transmit buffer is selected in cantbsel (see section 18.3.2.11, ?scan transmit buffer selection register (cantbsel) ? 76543210 r prio7 prio6 prio5 prio4 prio3 prio2 prio1 prio0 w reset: 00000000 figure 18-36. transmit buffer priority register (tbpr) module base + 0x00xe access: user read/write 1 1 read: anytime when txex ?g is set (see section 18.3.2.7, ?scan transmitter flag register (cantflg) ? and the corresponding transmit buffer is selected in cantbsel (see section 18.3.2.11, ?scan transmit buffer selection register (cantbsel) ? write: unimplemented 76543210 r tsr15 tsr14 tsr13 tsr12 tsr11 tsr10 tsr9 tsr8 w reset: xxxxxxxx figure 18-37. time stamp register ?high byte (tsrh) module base + 0x00xf access: user read/write 1 76543210 r tsr7 tsr6 tsr5 tsr4 tsr3 tsr2 tsr1 tsr0 w reset: xxxxxxxx figure 18-38. time stamp register ?low byte (tsrl)
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 618 freescale semiconductor 18.4 functional description 18.4.1 general this section provides a complete functional description of the mscan. 1 read: anytime when txex ?g is set (see section 18.3.2.7, ?scan transmitter flag register (cantflg) ? and the corresponding transmit buffer is selected in cantbsel (see section 18.3.2.11, ?scan transmit buffer selection register (cantbsel) ? write: unimplemented
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 619 18.4.2 message storage figure 18-39. user model for message buffer organization the mscan facilitates a sophisticated message storage system which addresses the requirements of a broad range of network applications. 18.4.2.1 message transmit background modern application layer software is built upon two fundamental assumptions: mscan rx0 rx1 can receive / transmit engine memory mapped i/o cpu bus mscan tx2 txe2 prio receiver transmitter rxbg txbg tx0 txe0 prio txbg tx1 prio txe1 txfg cpu bus rx2 rx3 rx4 rxf rxfg
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 620 freescale semiconductor any can node is able to send out a stream of scheduled messages without releasing the can bus between the two messages. such nodes arbitrate for the can bus immediately after sending the previous message and only release the can bus in case of lost arbitration. the internal message queue within any can node is organized such that the highest priority message is sent out ?st, if more than one message is ready to be sent. the behavior described in the bullets above cannot be achieved with a single transmit buffer. that buffer must be reloaded immediately after the previous message is sent. this loading process lasts a ?ite amount of time and must be completed within the inter-frame sequence (ifs) to be able to send an uninterrupted stream of messages. even if this is feasible for limited can bus speeds, it requires that the cpu reacts with short latencies to the transmit interrupt. a double buffer scheme de-couples the reloading of the transmit buffer from the actual message sending and, therefore, reduces the reactiveness requirements of the cpu. problems can arise if the sending of a message is ?ished while the cpu re-loads the second buffer. no buffer would then be ready for transmission, and the can bus would be released. at least three transmit buffers are required to meet the ?st of the above requirements under all circumstances. the mscan has three transmit buffers. the second requirement calls for some sort of internal prioritization which the mscan implements with the ?ocal priority?concept described in section 18.4.2.2, ?ransmit structures . 18.4.2.2 transmit structures the mscan triple transmit buffer scheme optimizes real-time performance by allowing multiple messages to be set up in advance. the three buffers are arranged as shown in figure 18-39 . all three buffers have a 13-byte data structure similar to the outline of the receive buffers (see section 18.3.3, ?rogrammers model of message storage ?. an additional transmit buffer priority register (tbpr) contains an 8-bit local priority ?ld (prio) (see section 18.3.3.4, ?ransmit buffer priority register (tbpr) ?. the remaining two bytes are used for time stamping of a message, if required (see section 18.3.3.5, ?ime stamp register (tsrh?srl) ?. to transmit a message, the cpu must identify an available transmit buffer, which is indicated by a set transmitter buffer empty (txex) ?g (see section 18.3.2.7, ?scan transmitter flag register (cantflg) ?. if a transmit buffer is available, the cpu must set a pointer to this buffer by writing to the cantbsel register (see section 18.3.2.11, ?scan transmit buffer selection register (cantbsel) ?. this makes the respective buffer accessible within the cantxfg address space (see section 18.3.3, ?rogrammers model of message storage ?. the algorithmic feature associated with the cantbsel register simpli?s the transmit buffer selection. in addition, this scheme makes the handler software simpler because only one address area is applicable for the transmit process, and the required address space is minimized. the cpu then stores the identi?r, the control bits, and the data content into one of the transmit buffers. finally, the buffer is ?gged as ready for transmission by clearing the associated txe ?g.
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 621 the mscan then schedules the message for transmission and signals the successful transmission of the buffer by setting the associated txe ?g. a transmit interrupt (see section 18.4.7.2, ?ransmit interrupt ? is generated 1 when txex is set and can be used to drive the application software to re-load the buffer. if more than one buffer is scheduled for transmission when the can bus becomes available for arbitration, the mscan uses the local priority setting of the three buffers to determine the prioritization. for this purpose, every transmit buffer has an 8-bit local priority ?ld (prio). the application software programs this ?ld when the message is set up. the local priority re?cts the priority of this particular message relative to the set of messages being transmitted from this node. the lowest binary value of the prio ?ld is de?ed to be the highest priority. the internal scheduling process takes place whenever the mscan arbitrates for the can bus. this is also the case after the occurrence of a transmission error. when a high priority message is scheduled by the application software, it may become necessary to abort a lower priority message in one of the three transmit buffers. because messages that are already in transmission cannot be aborted, the user must request the abort by setting the corresponding abort request bit (abtrq) (see section 18.3.2.9, ?scan transmitter message abort request register (cantarq) ?) the mscan then grants the request, if possible, by: 1. setting the corresponding abort acknowledge ?g (abtak) in the cantaak register. 2. setting the associated txe ?g to release the buffer. 3. generating a transmit interrupt. the transmit interrupt handler software can determine from the setting of the abtak ?g whether the message was aborted (abtak = 1) or sent (abtak = 0). 18.4.2.3 receive structures the received messages are stored in a ve stage input fifo. the ve message buffers are alternately mapped into a single memory area (see figure 18-39 ). the background receive buffer (rxbg) is exclusively associated with the mscan, but the foreground receive buffer (rxfg) is addressable by the cpu (see figure 18-39 ). this scheme simpli?s the handler software because only one address area is applicable for the receive process. all receive buffers have a size of 15 bytes to store the can control bits, the identi?r (standard or extended), the data contents, and a time stamp, if enabled (see section 18.3.3, ?rogrammers model of message storage ?. the receiver full ?g (rxf) (see section 18.3.2.5, ?scan receiver flag register (canrflg) ? signals the status of the foreground receive buffer. when the buffer contains a correctly received message with a matching identi?r, this ?g is set. on reception, each message is checked to see whether it passes the ?ter (see section 18.4.3, ?denti?r acceptance filter ? and simultaneously is written into the active rxbg. after successful reception of a valid message, the mscan shifts the content of rxbg into the receiver fifo, sets the rxf ?g, and generates a receive interrupt 2 (see section 18.4.7.3, ?eceive interrupt ? to the cpu. the users receive handler must read the received message from the rxfg and then reset the rxf ?g to acknowledge the interrupt and to release the foreground buffer. a new message, which can follow immediately after the ifs ?ld of the can frame, is received into the next available rxbg. if the mscan receives an invalid 1. the transmit interrupt occurs only if not masked. a polling scheme can be applied on txex also. 2. the receive interrupt occurs only if not masked. a polling scheme can be applied on rxf also.
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 622 freescale semiconductor message in its rxbg (wrong identi?r, transmission errors, etc.) the actual contents of the buffer will be over-written by the next message. the buffer will then not be shifted into the fifo. when the mscan module is transmitting, the mscan receives its own transmitted messages into the background receive buffer, rxbg, but does not shift it into the receiver fifo, generate a receive interrupt, or acknowledge its own messages on the can bus. the exception to this rule is in loopback mode (see section 18.3.2.2, ?scan control register 1 (canctl1) ? where the mscan treats its own messages exactly like all other incoming messages. the mscan receives its own transmitted messages in the event that it loses arbitration. if arbitration is lost, the mscan must be prepared to become a receiver. an overrun condition occurs when all receive message buffers in the fifo are ?led with correctly received messages with accepted identi?rs and another message is correctly received from the can bus with an accepted identi?r. the latter message is discarded and an error interrupt with overrun indication is generated if enabled (see section 18.4.7.5, ?rror interrupt ?. the mscan remains able to transmit messages while the receiver fifo is being ?led, but all incoming messages are discarded. as soon as a receive buffer in the fifo is available again, new valid messages will be accepted. 18.4.3 identi?r acceptance filter the mscan identi?r acceptance registers (see section 18.3.2.12, ?scan identi?r acceptance control register (canidac) ? de?e the acceptable patterns of the standard or extended identi?r (id[10:0] or id[28:0]). any of these bits can be marked ?ont care?in the mscan identi?r mask registers (see section 18.3.2.18, ?scan identi?r mask registers (canidmr0?anidmr7) ?. a ?ter hit is indicated to the application software by a set receive buffer full ?g (rxf = 1) and three bits in the canidac register (see section 18.3.2.12, ?scan identi?r acceptance control register (canidac) ?. these identi?r hit ?gs (idhit[2:0]) clearly identify the ?ter section that caused the acceptance. they simplify the application softwares task to identify the cause of the receiver interrupt. if more than one hit occurs (two or more ?ters match), the lower hit has priority. a very ?xible programmable generic identi?r acceptance ?ter has been introduced to reduce the cpu interrupt loading. the ?ter is programmable to operate in four different modes: two identi?r acceptance ?ters, each to be applied to: the full 29 bits of the extended identi?r and to the following bits of the can 2.0b frame: remote transmission request (rtr) identi?r extension (ide) substitute remote request (srr) the 11 bits of the standard identi?r plus the rtr and ide bits of the can 2.0a/b messages. this mode implements two ?ters for a full length can 2.0b compliant extended identi?r. although this mode can be used for standard identi?rs, it is recommended to use the four or eight identi?r acceptance ?ters. figure 18-40 shows how the ?st 32-bit ?ter bank (canidar0?anidar3, canidmr0?anidmr3) produces a ?ter 0 hit. similarly, the second ?ter bank (canidar4?anidar7, canidmr4?anidmr7) produces a ?ter 1 hit. four identi?r acceptance ?ters, each to be applied to:
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 623 the 14 most signi?ant bits of the extended identi?r plus the srr and ide bits of can 2.0b messages. the 11 bits of the standard identi?r, the rtr and ide bits of can 2.0a/b messages. figure 18-41 shows how the ?st 32-bit ?ter bank (canidar0?anidar3, canidmr0?anidmr3) produces ?ter 0 and 1 hits. similarly, the second ?ter bank (canidar4?anidar7, canidmr4?anidmr7) produces ?ter 2 and 3 hits. eight identi?r acceptance ?ters, each to be applied to the ?st 8 bits of the identi?r. this mode implements eight independent ?ters for the ?st 8 bits of a can 2.0a/b compliant standard identi?r or a can 2.0b compliant extended identi?r. figure 18-42 shows how the ?st 32-bit ?ter bank (canidar0?anidar3, canidmr0?anidmr3) produces ?ter 0 to 3 hits. similarly, the second ?ter bank (canidar4?anidar7, canidmr4?anidmr7) produces ?ter 4 to 7 hits. closed ?ter. no can message is copied into the foreground buffer rxfg, and the rxf ?g is never set. figure 18-40. 32-bit maskable identi?r acceptance filter id28 id21 idr0 id10 id3 idr0 id20 id15 idr1 id2 ide idr1 id14 id7 idr2 id10 id3 idr2 id6 rtr idr3 id10 id3 idr3 ac7 ac0 canidar0 am7 am0 canidmr0 ac7 ac0 canidar1 am7 am0 canidmr1 ac7 ac0 canidar2 am7 am0 canidmr2 ac7 ac0 canidar3 am7 am0 canidmr3 id accepted (filter 0 hit) can 2.0b extended identi?r can 2.0a/b standard identi?r
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 624 freescale semiconductor figure 18-41. 16-bit maskable identi?r acceptance filters id28 id21 idr0 id10 id3 idr0 id20 id15 idr1 id2 ide idr1 id14 id7 idr2 id10 id3 idr2 id6 rtr idr3 id10 id3 idr3 ac7 ac0 canidar0 am7 am0 canidmr0 ac7 ac0 canidar1 am7 am0 canidmr1 id accepted (filter 0 hit) ac7 ac0 canidar2 am7 am0 canidmr2 ac7 ac0 canidar3 am7 am0 canidmr3 id accepted (filter 1 hit) can 2.0b extended identi?r can 2.0a/b standard identi?r
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 625 figure 18-42. 8-bit maskable identi?r acceptance filters can 2.0b extended identi?r can 2.0a/b standard identi?r ac7 ac0 cidar3 am7 am0 cidmr3 id accepted (filter 3 hit) ac7 ac0 cidar2 am7 am0 cidmr2 id accepted (filter 2 hit) ac7 ac0 cidar1 am7 am0 cidmr1 id accepted (filter 1 hit) id28 id21 idr0 id10 id3 idr0 id20 id15 idr1 id2 ide idr1 id14 id7 idr2 id10 id3 idr2 id6 rtr idr3 id10 id3 idr3 ac7 ac0 cidar0 am7 am0 cidmr0 id accepted (filter 0 hit)
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 626 freescale semiconductor 18.4.3.1 protocol violation protection the mscan protects the user from accidentally violating the can protocol through programming errors. the protection logic implements the following features: the receive and transmit error counters cannot be written or otherwise manipulated. all registers which control the con?uration of the mscan cannot be modi?d while the mscan is on-line. the mscan has to be in initialization mode. the corresponding initrq/initak handshake bits in the canctl0/canctl1 registers (see section 18.3.2.1, ?scan control register 0 (canctl0) ? serve as a lock to protect the following registers: mscan control 1 register (canctl1) mscan bus timing registers 0 and 1 (canbtr0, canbtr1) mscan identi?r acceptance control register (canidac) mscan identi?r acceptance registers (canidar0?anidar7) mscan identi?r mask registers (canidmr0?anidmr7) the txcan is immediately forced to a recessive state when the mscan goes into the power down mode or initialization mode (see section 18.4.5.6, ?scan power down mode , and section 18.4.4.5, ?scan initialization mode ?. the mscan enable bit (cane) is writable only once in normal system operation modes, which provides further protection against inadvertently disabling the mscan. 18.4.3.2 clock system figure 18-43 shows the structure of the mscan clock generation circuitry. figure 18-43. mscan clocking scheme the clock source bit (clksrc) in the canctl1 register ( 18.3.2.2/18-592 ) de?es whether the internal canclk is connected to the output of a crystal oscillator (oscillator clock) or to the bus clock. the clock source has to be chosen such that the tight oscillator tolerance requirements (up to 0.4%) of the can protocol are met. additionally, for high can bus rates (1 mbps), a 45% to 55% duty cycle of the clock is required. if the bus clock is generated from a pll, it is recommended to select the oscillator clock rather than the bus clock due to jitter considerations, especially at the faster can bus rates. bus clock oscillator clock mscan canclk clksrc clksrc prescaler (1 .. 64) time quanta clock (tq)
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 627 for microcontrollers without a clock and reset generator (crg), canclk is driven from the crystal oscillator (oscillator clock). a programmable prescaler generates the time quanta (tq) clock from canclk. a time quantum is the atomic unit of time handled by the mscan. eqn. 18-2 a bit time is subdivided into three segments as described in the bosch can 2.0a/b speci?ation. (see figure 18-44 ): sync_seg: this segment has a ?ed length of one time quantum. signal edges are expected to happen within this section. time segment 1: this segment includes the prop_seg and the phase_seg1 of the can standard. it can be programmed by setting the parameter tseg1 to consist of 4 to 16 time quanta. time segment 2: this segment represents the phase_seg2 of the can standard. it can be programmed by setting the tseg2 parameter to be 2 to 8 time quanta long. eqn. 18-3 figure 18-44. segments within the bit time tq f canclk prescaler value ( ) ---------------------------------------------------- -- = bit rate f tq number of time quanta () -------------------------------------------------------------------------------- - = sync_seg time segment 1 time segment 2 1 4 ... 16 2 ... 8 8 ... 25 time quanta = 1 bit time nrz signal sample point (single or triple sampling) (prop_seg + phase_seg1) (phase_seg2) transmit point
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 628 freescale semiconductor the synchronization jump width (see the bosch can 2.0a/b speci?ation for details) can be programmed in a range of 1 to 4 time quanta by setting the sjw parameter. the sync_seg, tseg1, tseg2, and sjw parameters are set by programming the mscan bus timing registers (canbtr0, canbtr1) (see section 18.3.2.3, ?scan bus timing register 0 (canbtr0) and section 18.3.2.4, ?scan bus timing register 1 (canbtr1) ?. table 18-37 gives an overview of the bosch can 2.0a/b speci?ation compliant segment settings and the related parameter values. note it is the users responsibility to ensure the bit time settings are in compliance with the can standard. 18.4.4 modes of operation 18.4.4.1 normal system operating modes the mscan module behaves as described within this speci?ation in all normal system operating modes. write restrictions exist for some registers. table 18-36. time segment syntax syntax description sync_seg system expects transitions to occur on the can bus during this period. transmit point a node in transmit mode transfers a new value to the can bus at this point. sample point a node in receive mode samples the can bus at this point. if the three samples per bit option is selected, then this point marks the position of the third sample. table 18-37. bosch can 2.0a/b compliant bit time segment settings time segment 1 tseg1 time segment 2 tseg2 synchronization jump width sjw 5 .. 10 4 .. 9 2 1 1 .. 2 0 .. 1 4 .. 11 3 .. 10 3 2 1 .. 3 0 .. 2 5 .. 12 4 .. 11 4 3 1 .. 4 0 .. 3 6 .. 13 5 .. 12 5 4 1 .. 4 0 .. 3 7 .. 14 6 .. 13 6 5 1 .. 4 0 .. 3 8 .. 15 7 .. 14 7 6 1 .. 4 0 .. 3 9 .. 16 8 .. 15 8 7 1 .. 4 0 .. 3
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 629 18.4.4.2 special system operating modes the mscan module behaves as described within this speci?ation in all special system operating modes. write restrictions which exist on speci? registers in normal modes are lifted for test purposes in special modes. 18.4.4.3 emulation modes in all emulation modes, the mscan module behaves just like in normal system operating modes as described within this speci?ation. 18.4.4.4 listen-only mode in an optional can bus monitoring mode (listen-only), the can node is able to receive valid data frames and valid remote frames, but it sends only ?ecessive?bits on the can bus. in addition, it cannot start a transmission. if the mac sub-layer is required to send a ?ominant bit (ack bit, overload ?g, or active error ?g), the bit is rerouted internally so that the mac sub-layer monitors this ?ominant?bit, although the can bus may remain in recessive state externally. 18.4.4.5 mscan initialization mode the mscan enters initialization mode when it is enabled (cane=1). when entering initialization mode during operation, any on-going transmission or reception is immediately aborted and synchronization to the can bus is lost, potentially causing can protocol violations. to protect the can bus system from fatal consequences of violations, the mscan immediately drives txcan into a recessive state. note the user is responsible for ensuring that the mscan is not active when initialization mode is entered. the recommended procedure is to bring the mscan into sleep mode (slprq = 1 and slpak = 1) before setting the initrq bit in the canctl0 register. otherwise, the abort of an on-going message can cause an error condition and can impact other can bus devices. in initialization mode, the mscan is stopped. however, interface registers remain accessible. this mode is used to reset the canctl0, canrflg, canrier, cantflg, cantier, cantarq, cantaak, and cantbsel registers to their default values. in addition, the mscan enables the con?uration of the canbtr0, canbtr1 bit timing registers; canidac; and the canidar, canidmr message ?ters. see section 18.3.2.1, ?scan control register 0 (canctl0) , for a detailed description of the initialization mode.
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 630 freescale semiconductor figure 18-45. initialization request/acknowledge cycle due to independent clock domains within the mscan, initrq must be synchronized to all domains by using a special handshake mechanism. this handshake causes additional synchronization delay (see figure 18-45 ). if there is no message transfer ongoing on the can bus, the minimum delay will be two additional bus clocks and three additional can clocks. when all parts of the mscan are in initialization mode, the initak ?g is set. the application software must use initak as a handshake indication for the request (initrq) to go into initialization mode. note the cpu cannot clear initrq before initialization mode (initrq = 1 and initak = 1) is active. 18.4.5 low-power options if the mscan is disabled (cane = 0), the mscan clocks are stopped for power saving. if the mscan is enabled (cane = 1), the mscan has two additional modes with reduced power consumption, compared to normal mode: sleep and power down mode. in sleep mode, power consumption is reduced by stopping all clocks except those to access the registers from the cpu side. in power down mode, all clocks are stopped and no power is consumed. table 18-38 summarizes the combinations of mscan and cpu modes. a particular combination of modes is entered by the given settings on the cswai and slprq/slpak bits. sync sync bus cloc k domain can cloc k domain cpu init request init flag initak flag initrq sync. initak sync. initrq initak
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 631 18.4.5.1 operation in run mode as shown in table 18-38 , only mscan sleep mode is available as low power option when the cpu is in run mode. 18.4.5.2 operation in wait mode the wai instruction puts the mcu in a low power consumption stand-by mode. if the cswai bit is set, additional power can be saved in power down mode because the cpu clocks are stopped. after leaving this power down mode, the mscan restarts and enters normal mode again. while the cpu is in wait mode, the mscan can be operated in normal mode and generate interrupts (registers can be accessed via background debug mode). 18.4.5.3 operation in stop mode the stop instruction puts the mcu in a low power consumption stand-by mode. in stop mode, the mscan is set in power down mode regardless of the value of the slprq/slpak and cswai bits ( table 18-38 ). 18.4.5.4 mscan normal mode this is a non-power-saving mode. enabling the mscan puts the module from disabled mode into normal mode. in this mode the module can either be in initialization mode or out of initialization mode. see section 18.4.4.5, ?scan initialization mode ? table 18-38. cpu vs. mscan operating modes cpu mode mscan mode normal reduced power consumption sleep power down disabled (cane=0) run cswai = x 1 slprq = 0 slpak = 0 1 ??means don? care. cswai = x slprq = 1 slpak = 1 cswai = x slprq = x slpak = x wait cswai = 0 slprq = 0 slpak = 0 cswai = 0 slprq = 1 slpak = 1 cswai = 1 slprq = x slpak = x cswai = x slprq = x slpak = x stop cswai = x slprq = x slpak = x cswai = x slprq = x slpak = x
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 632 freescale semiconductor 18.4.5.5 mscan sleep mode the cpu can request the mscan to enter this low power mode by asserting the slprq bit in the canctl0 register. the time when the mscan enters sleep mode depends on a ?ed synchronization delay and its current activity: if there are one or more message buffers scheduled for transmission (txex = 0), the mscan will continue to transmit until all transmit message buffers are empty (txex = 1, transmitted successfully or aborted) and then goes into sleep mode. if the mscan is receiving, it continues to receive and goes into sleep mode as soon as the can bus next becomes idle. if the mscan is neither transmitting nor receiving, it immediately goes into sleep mode. figure 18-46. sleep request / acknowledge cycle note the application software must avoid setting up a transmission (by clearing one or more txex ?g(s)) and immediately request sleep mode (by setting slprq). whether the mscan starts transmitting or goes into sleep mode directly depends on the exact sequence of operations. if sleep mode is active, the slprq and slpak bits are set ( figure 18-46 ). the application software must use slpak as a handshake indication for the request (slprq) to go into sleep mode. when in sleep mode (slprq = 1 and slpak = 1), the mscan stops its internal clocks. however, clocks that allow register accesses from the cpu side continue to run. if the mscan is in bus-off state, it stops counting the 128 occurrences of 11 consecutive recessive bits due to the stopped clocks. txcan remains in a recessive state. if rxf = 1, the message can be read and rxf can be cleared. shifting a new message into the foreground buffer of the receiver fifo (rxfg) does not take place while in sleep mode. it is possible to access the transmit buffers and to clear the associated txe ?gs. no message abort takes place while in sleep mode. sync sync bus cloc k domain can cloc k domain mscan in sleep mode cpu sleep request slprq flag slpak flag slprq sync. slpak sync. slprq slpak
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 633 if the wupe bit in canctl0 is not asserted, the mscan will mask any activity it detects on can. rxcan is therefore held internally in a recessive state. this locks the mscan in sleep mode. wupe must be set before entering sleep mode to take effect. the mscan is able to leave sleep mode (wake up) only when: can bus activity occurs and wupe = 1 or the cpu clears the slprq bit note the cpu cannot clear the slprq bit before sleep mode (slprq = 1 and slpak = 1) is active. after wake-up, the mscan waits for 11 consecutive recessive bits to synchronize to the can bus. as a consequence, if the mscan is woken-up by a can frame, this frame is not received. the receive message buffers (rxfg and rxbg) contain messages if they were received before sleep mode was entered. all pending actions will be executed upon wake-up; copying of rxbg into rxfg, message aborts and message transmissions. if the mscan remains in bus-off state after sleep mode was exited, it continues counting the 128 occurrences of 11 consecutive recessive bits. 18.4.5.6 mscan power down mode the mscan is in power down mode ( table 18-38 ) when cpu is in stop mode or cpu is in wait mode and the cswai bit is set when entering the power down mode, the mscan immediately stops all ongoing transmissions and receptions, potentially causing can protocol violations. to protect the can bus system from fatal consequences of violations to the above rule, the mscan immediately drives txcan into a recessive state. note the user is responsible for ensuring that the mscan is not active when power down mode is entered. the recommended procedure is to bring the mscan into sleep mode before the stop or wai instruction (if cswai is set) is executed. otherwise, the abort of an ongoing message can cause an error condition and impact other can bus devices. in power down mode, all clocks are stopped and no registers can be accessed. if the mscan was not in sleep mode before power down mode became active, the module performs an internal recovery cycle after powering up. this causes some ?ed delay before the module enters normal mode again.
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 634 freescale semiconductor 18.4.5.7 disabled mode the mscan is in disabled mode out of reset (cane=0). all module clocks are stopped for power saving, however the register map can still be accessed as speci?d. 18.4.5.8 programmable wake-up function the mscan can be programmed to wake up from sleep or power down mode as soon as can bus activity is detected (see control bit wupe in mscan control register 0 (canctl0). the sensitivity to existing can bus action can be modi?d by applying a low-pass ?ter function to the rxcan input line (see control bit wupm in section 18.3.2.2, ?scan control register 1 (canctl1) ?. this feature can be used to protect the mscan from wake-up due to short glitches on the can bus lines. such glitches can result from?or example?lectromagnetic interference within noisy environments. 18.4.6 reset initialization the reset state of each individual bit is listed in section 18.3.2, ?egister descriptions , which details all the registers and their bit-?lds. 18.4.7 interrupts this section describes all interrupts originated by the mscan. it documents the enable bits and generated ?gs. each interrupt is listed and described separately. 18.4.7.1 description of interrupt operation the mscan supports four interrupt vectors (see table 18-39 ), any of which can be individually masked (for details see section 18.3.2.6, ?scan receiver interrupt enable register (canrier) ?to section 18.3.2.8, ?scan transmitter interrupt enable register (cantier) ?. refer to the device overview section to determine the dedicated interrupt vector addresses. 18.4.7.2 transmit interrupt at least one of the three transmit buffers is empty (not scheduled) and can be loaded to schedule a message for transmission. the txex ?g of the empty message buffer is set. table 18-39. interrupt vectors interrupt source ccr mask local enable wake-up interrupt (wupif) i bit canrier (wupie) error interrupts interrupt (cscif, ovrif) i bit canrier (cscie, ovrie) receive interrupt (rxf) i bit canrier (rxfie) transmit interrupts (txe[2:0]) i bit cantier (txeie[2:0])
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 635 18.4.7.3 receive interrupt a message is successfully received and shifted into the foreground buffer (rxfg) of the receiver fifo. this interrupt is generated immediately after receiving the eof symbol. the rxf ?g is set. if there are multiple messages in the receiver fifo, the rxf ?g is set as soon as the next message is shifted to the foreground buffer. 18.4.7.4 wake-up interrupt a wake-up interrupt is generated if activity on the can bus occurs during mscan sleep or power-down mode. note this interrupt can only occur if the mscan was in sleep mode (slprq = 1 and slpak = 1) before entering power down mode, the wake-up option is enabled (wupe = 1), and the wake-up interrupt is enabled (wupie = 1). 18.4.7.5 error interrupt an error interrupt is generated if an overrun of the receiver fifo, error, warning, or bus-off condition occurrs. mscan receiver flag register (canrflg) indicates one of the following conditions: overrun an overrun condition of the receiver fifo as described in section 18.4.2.3, ?eceive structures , occurred. can status change ?the actual value of the transmit and receive error counters control the can bus state of the mscan. as soon as the error counters skip into a critical range (tx/rx-warning, tx/rx-error, bus-off) the mscan ?gs an error condition. the status change, which caused the error condition, is indicated by the tstat and rstat ?gs (see section 18.3.2.5, ?scan receiver flag register (canrflg) and section 18.3.2.6, ?scan receiver interrupt enable register (canrier) ?. 18.4.7.6 interrupt acknowledge interrupts are directly associated with one or more status ?gs in either the mscan receiver flag register (canrflg) or the mscan transmitter flag register (cantflg) . interrupts are pending as long as one of the corresponding ?gs is set. the ?gs in canrflg and cantflg must be reset within the interrupt handler to handshake the interrupt. the ?gs are reset by writing a 1 to the corresponding bit position. a ?g cannot be cleared if the respective condition prevails. note it must be guaranteed that the cpu clears only the bit causing the current interrupt. for this reason, bit manipulation instructions (bset) must not be used to clear interrupt ?gs. these instructions may cause accidental clearing of interrupt ?gs which are set after entering the current interrupt service routine.
freescales scalable controller area network (s12mscanv3) mc9s12g family reference manual, rev.1.23 636 freescale semiconductor 18.5 initialization/application information 18.5.1 mscan initialization the procedure to initially start up the mscan module out of reset is as follows: 1. assert cane 2. write to the con?uration registers in initialization mode 3. clear initrq to leave initialization mode if the con?uration of registers which are only writable in initialization mode shall be changed: 1. bring the module into sleep mode by setting slprq and awaiting slpak to assert after the can bus becomes idle. 2. enter initialization mode: assert initrq and await initak 3. write to the con?uration registers in initialization mode 4. clear initrq to leave initialization mode and continue 18.5.2 bus-off recovery the bus-off recovery is user con?urable. the bus-off state can either be left automatically or on user request. for reasons of backwards compatibility, the mscan defaults to automatic recovery after reset. in this case, the mscan will become error active again after counting 128 occurrences of 11 consecutive recessive bits on the can bus (see the bosch can 2.0 a/b speci?ation for details). if the mscan is con?ured for user request (borm set in mscan control register 1 (canctl1) ), the recovery from bus-off starts after both independent events have become true: 128 occurrences of 11 consecutive recessive bits on the can bus have been monitored bohold in mscan miscellaneous register (canmisc) has been cleared by the user these two events may occur in any order.
mc9s12g family reference manual, rev.1.23 freescale semiconductor 637 chapter 19 pulse-width modulator (s12pwm8b8cv2) 19.1 introduction the version 2 of s12 pwm module is a channel scalable and optimized implementation of s12 pwm8b8c version 1. the channel is scalable in pairs from pwm0 to pwm7 and the available channel number is 2, 4, 6 and 8. the shutdown feature has been removed and the ?xibility to select one of four clock sources per channel has improved. if the corresponding channels exist and shutdown feature is not used, the version 2 is fully software compatible to version 1. 19.1.1 features the scalable pwm block includes these distinctive features: up to eight independent pwm channels, scalable in pairs (pwm0 to pwm7) available channel number could be 2, 4, 6, 8 (refer to device speci?ation for exact number) programmable period and duty cycle for each channel dedicated counter for each pwm channel programmable pwm enable/disable for each channel software selection of pwm duty pulse polarity for each channel period and duty cycle are double buffered. change takes effect when the end of the effective period is reached (pwm counter reaches zero) or when the channel is disabled. programmable center or left aligned outputs on individual channels up to eight 8-bit channel or four 16-bit channel pwm resolution four clock sources (a, b, sa, and sb) provide for a wide range of frequencies programmable clock select logic 19.1.2 modes of operation there is a software programmable option for low power consumption in wait mode that disables the input clock to the prescaler. in freeze mode there is a software programmable option to disable the input clock to the prescaler. this is useful for emulation. wait: the prescaler keeps on running, unless pswai in pwmctl is set to 1. freeze: the prescaler keeps on running, unless pfrz in pwmctl is set to 1.
pulse-width modulator (s12pwm8b8cv2) mc9s12g family reference manual, rev.1.23 638 freescale semiconductor 19.1.3 block diagram figure 19-1 shows the block diagram for the 8-bit up to 8-channel scalable pwm block. figure 19-1. scalable pwm block diagram 19.2 external signal description the scalable pwm module has a selected number of external pins. refer to device speci?ation for exact number. 19.2.1 pwm7 - pwm0 ?pwm channel 7 - 0 those pins serve as waveform output of pwm channel 7 - 0. period and duty counter channel 6 clock select pwm clock period and duty counter channel 5 period and duty counter channel 4 period and duty counter channel 3 period and duty counter channel 2 period and duty counter channel 1 alignment polarity control pwm8b8c pwm6 pwm5 pwm4 pwm3 pwm2 pwm1 enable pwm channels period and duty counter channel 7 period and duty counter channel 0 pwm0 pwm7 bus clock maximum possible channels, scalable in pairs from pwm0 to pwm7.
pulse-width modulator (s12pwm8b8cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 639 19.3 memory map and register de?ition 19.3.1 module memory map this section describes the content of the registers in the scalable pwm module. the base address of the scalable pwm module is determined at the mcu level when the mcu is de?ed. the register decode map is ?ed and begins at the ?st address of the module address offset. the ?ure below shows the registers associated with the scalable pwm and their relative offset from the base address. the register detail description follows the order they appear in the register map. reserved bits within a register will always read as 0 and the write will be unimplemented. unimplemented functions are indicated by shading the bit. note register address = base address + address offset, where the base address is de?ed at the mcu level and the address offset is de?ed at the module level. 19.3.2 register descriptions this section describes in detail all the registers and register bits in the scalable pwm module. register name bit 7 6 5 4 3 2 1 bit 0 0x0000 pwme 1 r pwme7 pwme6 pwme5 pwme4 pwme3 pwme2 pwme1 pwme0 w 0x0001 pwmpol 1 r ppol7 ppol6 ppol5 ppol4 ppol3 ppol2 ppol1 ppol0 w 0x0002 pwmclk 1 r pclk7 pclkl6 pclk5 pclk4 pclk3 pclk2 pclk1 pclk0 w 0x0003 pwmprclk r0 pckb2 pckb1 pckb0 0 pcka2 pcka1 pcka0 w 0x0004 pwmcae 1 r cae7 cae6 cae5 cae4 cae3 cae2 cae1 cae0 w 0x0005 pwmctl 1 r con67 con45 con23 con01 pswai pfrz 00 w 0x0006 pwmclkab 1 r pclkab7 pclkab6 pclkab5 pclkab4 pclkab3 pclkab2 pclkab1 pclkab0 w = unimplemented or reserved figure 19-2. the scalable pwm register summary (sheet 1 of 4)
pulse-width modulator (s12pwm8b8cv2) mc9s12g family reference manual, rev.1.23 640 freescale semiconductor 0x0007 reserved r00 0 00000 w 0x0008 pwmscla r bit 7 6 5 4 3 2 1 bit 0 w 0x0009 pwmsclb r bit 7 6 5 4 3 2 1 bit 0 w 0x000a reserved r00 0 00000 w 0x000b reserved r00 0 00000 w 0x000c pwmcnt0 2 r bit 7 6 5 4 3 2 1 bit 0 w00 0 00000 0x000d pwmcnt1 2 r bit 7 6 5 4 3 2 1 bit 0 w00 0 00000 0x000e pwmcnt2 2 r bit 7 6 5 4 3 2 1 bit 0 w00 0 00000 0x000f pwmcnt3 2 r bit 7 6 5 4 3 2 1 bit 0 w00 0 00000 0x0010 pwmcnt4 2 r bit 7 6 5 4 3 2 1 bit 0 w00 0 00000 0x0011 pwmcnt5 2 r bit 7 6 5 4 3 2 1 bit 0 w00 0 00000 0x0012 pwmcnt6 2 r bit 7 6 5 4 3 2 1 bit 0 w00 0 00000 0x0013 pwmcnt7 2 r bit 7 6 5 4 3 2 1 bit 0 w00 0 00000 0x0014 pwmper0 2 r bit 7 6 5 4 3 2 1 bit 0 w 0x0015 pwmper1 2 r bit 7 6 5 4 3 2 1 bit 0 w register name bit 7 6 5 4 3 2 1 bit 0 = unimplemented or reserved figure 19-2. the scalable pwm register summary (sheet 1 of 4)
pulse-width modulator (s12pwm8b8cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 641 0x0016 pwmper2 2 r bit 7 6 5 4 3 2 1 bit 0 w 0x0017 pwmper3 2 r bit 7 6 5 4 3 2 1 bit 0 w 0x0018 pwmper4 2 r bit 7 6 5 4 3 2 1 bit 0 w 0x0019 pwmper5 2 r bit 7 6 5 4 3 2 1 bit 0 w 0x001a pwmper6 2 r bit 7 6 5 4 3 2 1 bit 0 w 0x001b pwmper7 2 r bit 7 6 5 4 3 2 1 bit 0 w 0x001c pwmdty0 2 r bit 7 6 5 4 3 2 1 bit 0 w 0x001d pwmdty1 2 r bit 7 6 5 4 3 2 1 bit 0 w 0x001e pwmdty2 2 r bit 7 6 5 4 3 2 1 bit 0 w 0x001f pwmdty3 2 r bit 7 6 5 4 3 2 1 bit 0 w 0x0010 pwmdty4 2 r bit 7 6 5 4 3 2 1 bit 0 w 0x0021 pwmdty5 2 r bit 7 6 5 4 3 2 1 bit 0 w 0x0022 pwmdty6 2 r bit 7 6 5 4 3 2 1 bit 0 w 0x0023 pwmdty7 2 r bit 7 6 5 4 3 2 1 bit 0 w 0x0024 reserved r00 0 00000 w register name bit 7 6 5 4 3 2 1 bit 0 = unimplemented or reserved figure 19-2. the scalable pwm register summary (sheet 1 of 4)
pulse-width modulator (s12pwm8b8cv2) mc9s12g family reference manual, rev.1.23 642 freescale semiconductor 19.3.2.1 pwm enable register (pwme) each pwm channel has an enable bit (pwmex) to start its waveform output. when any of the pwmex bits are set (pwmex = 1), the associated pwm output is enabled immediately. however, the actual pwm waveform is not available on the associated pwm output until its clock source begins its next cycle due to the synchronization of pwmex and the clock source. note the ?st pwm cycle after enabling the channel can be irregular. an exception to this is when channels are concatenated. once concatenated mode is enabled (conxx bits set in pwmctl register), enabling/disabling the corresponding 16-bit pwm channel is controlled by the low order pwmex bit. in this case, the high order bytes pwmex bits have no effect and their corresponding pwm output lines are disabled. while in run mode, if all existing pwm channels are disabled (pwmex? = 0), the prescaler counter shuts off for power savings. read: anytime write: anytime 0x0025 reserved r00 0 00000 w 0x0026 reserved r00 0 00000 w 0x0027 reserved r00 0 00000 w 1 the related bit is available only if corresponding channel exists. 2 the register is available only if corresponding channel exists. module base + 0x0000 76543210 r pwme7 pwme6 pwme5 pwme4 pwme3 pwme2 pwme1 pwme0 w reset 0 0 0 00000 figure 19-3. pwm enable register (pwme) register name bit 7 6 5 4 3 2 1 bit 0 = unimplemented or reserved figure 19-2. the scalable pwm register summary (sheet 1 of 4)
pulse-width modulator (s12pwm8b8cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 643 19.3.2.2 pwm polarity register (pwmpol) the starting polarity of each pwm channel waveform is determined by the associated ppolx bit in the pwmpol register. if the polarity bit is one, the pwm channel output is high at the beginning of the cycle and then goes low when the duty count is reached. conversely, if the polarity bit is zero, the output starts low and then goes high when the duty count is reached. table 19-2. pwme field descriptions note: bits related to available channels have functional signi?ance. writing to unavailable bits has no effect. read from unavailable bits return a zero field description 7 pwme7 pulse width channel 7 enable 0 pulse width channel 7 is disabled. 1 pulse width channel 7 is enabled. the pulse modulated signal becomes available at pwm output bit 7 when its clock source begins its next cycle. 6 pwme6 pulse width channel 6 enable 0 pulse width channel 6 is disabled. 1 pulse width channel 6 is enabled. the pulse modulated signal becomes available at pwm output bit 6 when its clock source begins its next cycle. if con67=1, then bit has no effect and pwm output line 6 is disabled. 5 pwme5 pulse width channel 5 enable 0 pulse width channel 5 is disabled. 1 pulse width channel 5 is enabled. the pulse modulated signal becomes available at pwm output bit 5 when its clock source begins its next cycle. 4 pwme4 pulse width channel 4 enable 0 pulse width channel 4 is disabled. 1 pulse width channel 4 is enabled. the pulse modulated signal becomes available at pwm, output bit 4 when its clock source begins its next cycle. if con45 = 1, then bit has no effect and pwm output line 4 is disabled. 3 pwme3 pulse width channel 3 enable 0 pulse width channel 3 is disabled. 1 pulse width channel 3 is enabled. the pulse modulated signal becomes available at pwm, output bit 3 when its clock source begins its next cycle. 2 pwme2 pulse width channel 2 enable 0 pulse width channel 2 is disabled. 1 pulse width channel 2 is enabled. the pulse modulated signal becomes available at pwm, output bit 2 when its clock source begins its next cycle. if con23 = 1, then bit has no effect and pwm output line 2 is disabled. 1 pwme1 pulse width channel 1 enable 0 pulse width channel 1 is disabled. 1 pulse width channel 1 is enabled. the pulse modulated signal becomes available at pwm, output bit 1 when its clock source begins its next cycle. 0 pwme0 pulse width channel 0 enable 0 pulse width channel 0 is disabled. 1 pulse width channel 0 is enabled. the pulse modulated signal becomes available at pwm, output bit 0 when its clock source begins its next cycle. if con01 = 1, then bit has no effect and pwm output line 0 is disabled.
pulse-width modulator (s12pwm8b8cv2) mc9s12g family reference manual, rev.1.23 644 freescale semiconductor read: anytime write: anytime note ppolx register bits can be written anytime. if the polarity is changed while a pwm signal is being generated, a truncated or stretched pulse can occur during the transition 19.3.2.3 pwm clock select register (pwmclk) each pwm channel has a choice of four clocks to use as the clock source for that channel as described below. read: anytime write: anytime note register bits pclk0 to pclk7 can be written anytime. if a clock select is changed while a pwm signal is being generated, a truncated or stretched pulse can occur during the transition. module base + 0x0001 76543210 r ppol7 ppol6 ppol5 ppol4 ppol3 ppol2 ppol1 ppol0 w reset 0 0 0 00000 figure 19-4. pwm polarity register (pwmpol) table 19-3. pwmpol field descriptions note: bits related to available channels have functional signi?ance. writing to unavailable bits has no effect. read from unavailable bits return a zero field description 7? ppol[7:0] p ulse width channel 7? polarity bits 0 pwm channel 7? outputs are low at the beginning of the period, then go high when the duty count is reached. 1 pwm channel 7? outputs are high at the beginning of the period, then go low when the duty count is reached. module base + 0x0002 76543210 r pclk7 pclkl6 pclk5 pclk4 pclk3 pclk2 pclk1 pclk0 w reset 0 0 0 00000 figure 19-5. pwm clock select register (pwmclk)
pulse-width modulator (s12pwm8b8cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 645 the clock source of each pwm channel is determined by pclkx bits in pwmclk and pclkabx bits in pwmclkab (see section 19.3.2.7, ?wm clock a/b select register (pwmclkab) ). for channel 0, 1, 4, 5, the selection is shown in table 19-5 ; for channel 2, 3, 6, 7, the selection is shown in table 19-6 . table 19-5. pwm channel 0, 1, 4, 5 clock source selection table 19-6. pwm channel 2, 3, 6, 7 clock source selection 19.3.2.4 pwm prescale clock select register (pwmprclk) this register selects the prescale clock source for clocks a and b independently. read: anytime write: anytime note pckb2? and pcka2? register bits can be written anytime. if the clock pre-scale is changed while a pwm signal is being generated, a truncated or stretched pulse can occur during the transition. table 19-4. pwmclk field descriptions note: bits related to available channels have functional signi?ance. writing to unavailable bits has no effect. read from unavailable bits return a zero field description 7-0 pclk[7:0] pulse width channel 7-0 clock select 0 clock a or b is the clock source for pwm channel 7-0, as shown in table 19-5 and table 19-6 . 1 clock sa or sb is the clock source for pwm channel 7-0, as shown in table 19-5 and table 19-6 . pclkab[0,1,4,5] pclk[0,1,4,5] clock source selection 0 0 clock a 0 1 clock sa 1 0 clock b 1 1 clock sb pclkab[2,3,6,7] pclk[2,3,6,7] clock source selection 0 0 clock b 0 1 clock sb 1 0 clock a 1 1 clock sa module base + 0x0003 76543210 r0 pckb2 pckb1 pckb0 0 pcka2 pcka1 pcka0 w reset 0 0 0 00000 = unimplemented or reserved figure 19-6. pwm prescale clock select register (pwmprclk)
pulse-width modulator (s12pwm8b8cv2) mc9s12g family reference manual, rev.1.23 646 freescale semiconductor s 19.3.2.5 pwm center align enable register (pwmcae) the pwmcae register contains eight control bits for the selection of center aligned outputs or left aligned outputs for each pwm channel. if the caex bit is set to a one, the corresponding pwm output will be center aligned. if the caex bit is cleared, the corresponding pwm output will be left aligned. see section 19.4.2.5, ?eft aligned outputs and section 19.4.2.6, ?enter aligned outputs for a more detailed description of the pwm output modes. read: anytime write: anytime note write these bits only when the corresponding channel is disabled. table 19-7. pwmprclk field descriptions field description 6? pckb[2:0] prescaler select for clock b clock b is one of two clock sources which can be used for all channels. these three bits determine the rate of clock b, as shown in table 19-8 . 2? pcka[2:0] prescaler select for clock a clock a is one of two clock sources which can be used for all channels. these three bits determine the rate of clock a, as shown in table 19-8 . table 19-8. clock a or clock b prescaler selects pcka/b2 pcka/b1 pcka/b0 value of clock a/b 0 0 0 bus clock 0 0 1 bus clock / 2 0 1 0 bus clock / 4 0 1 1 bus clock / 8 1 0 0 bus clock / 16 1 0 1 bus clock / 32 1 1 0 bus clock / 64 1 1 1 bus clock / 128 module base + 0x0004 76543210 r cae7 cae6 cae5 cae4 cae3 cae2 cae1 cae0 w reset 0 0 0 00000 figure 19-7. pwm center align enable register (pwmcae)
pulse-width modulator (s12pwm8b8cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 647 19.3.2.6 pwm control register (pwmctl) the pwmctl register provides for various control of the pwm module. read: anytime write: anytime there are up to four control bits for concatenation, each of which is used to concatenate a pair of pwm channels into one 16-bit channel. if the corresponding channels do not exist on a particular derivative, then writes to these bits have no effect and reads will return zeroes. when channels 6 and 7are concatenated, channel 6 registers become the high order bytes of the double byte channel. when channels 4 and 5 are concatenated, channel 4 registers become the high order bytes of the double byte channel. when channels 2 and 3 are concatenated, channel 2 registers become the high order bytes of the double byte channel. when channels 0 and 1 are concatenated, channel 0 registers become the high order bytes of the double byte channel. see section 19.4.2.7, ?wm 16-bit functions for a more detailed description of the concatenation pwm function. note change these bits only when both corresponding channels are disabled. table 19-9. pwmcae field descriptions note: bits related to available channels have functional signi?ance. writing to unavailable bits has no effect. read from unavailable bits return a zero field description 7? cae[7:0] center aligned output modes on channels 7? 0 channels 7? operate in left aligned output mode. 1 channels 7? operate in center aligned output mode. module base + 0x0005 76543210 r con67 con45 con23 con01 pswai pfrz 00 w reset 0 0 0 00000 = unimplemented or reserved figure 19-8. pwm control register (pwmctl)
pulse-width modulator (s12pwm8b8cv2) mc9s12g family reference manual, rev.1.23 648 freescale semiconductor 19.3.2.7 pwm clock a/b select register (pwmclkab) each pwm channel has a choice of four clocks to use as the clock source for that channel as described below. table 19-10. pwmctl field descriptions note: bits related to available channels have functional signi?ance. writing to unavailable bits has no effect. read from unavailable bits return a zero field description 7 con67 concatenate channels 6 and 7 0 channels 6 and 7 are separate 8-bit pwms. 1 channels 6 and 7 are concatenated to create one 16-bit pwm channel. channel 6 becomes the high order byte and channel 7 becomes the low order byte. channel 7 output pin is used as the output for this 16-bit pwm (bit 7 of port pwmp). channel 7 clock select control-bit determines the clock source, channel 7 polarity bit determines the polarity, channel 7 enable bit enables the output and channel 7 center aligned enable bit determines the output mode. 6 con45 concatenate channels 4 and 5 0 channels 4 and 5 are separate 8-bit pwms. 1 channels 4 and 5 are concatenated to create one 16-bit pwm channel. channel 4 becomes the high order byte and channel 5 becomes the low order byte. channel 5 output pin is used as the output for this 16-bit pwm (bit 5 of port pwmp). channel 5 clock select control-bit determines the clock source, channel 5 polarity bit determines the polarity, channel 5 enable bit enables the output and channel 5 center aligned enable bit determines the output mode. 5 con23 concatenate channels 2 and 3 0 channels 2 and 3 are separate 8-bit pwms. 1 channels 2 and 3 are concatenated to create one 16-bit pwm channel. channel 2 becomes the high order byte and channel 3 becomes the low order byte. channel 3 output pin is used as the output for this 16-bit pwm (bit 3 of port pwmp). channel 3 clock select control-bit determines the clock source, channel 3 polarity bit determines the polarity, channel 3 enable bit enables the output and channel 3 center aligned enable bit determines the output mode. 4 con01 concatenate channels 0 and 1 0 channels 0 and 1 are separate 8-bit pwms. 1 channels 0 and 1 are concatenated to create one 16-bit pwm channel. channel 0 becomes the high order byte and channel 1 becomes the low order byte. channel 1 output pin is used as the output for this 16-bit pwm (bit 1 of port pwmp). channel 1 clock select control-bit determines the clock source, channel 1 polarity bit determines the polarity, channel 1 enable bit enables the output and channel 1 center aligned enable bit determines the output mode. 3 pswai pwm stops in wait mode enabling this bit allows for lower power consumption in wait mode by disabling the input clock to the prescaler. 0 allow the clock to the prescaler to continue while in wait mode. 1 stop the input clock to the prescaler whenever the mcu is in wait mode. 2 pfrz pwm counters stop in freeze mode ?in freeze mode, there is an option to disable the input clock to the prescaler by setting the pfrz bit in the pwmctl register. if this bit is set, whenever the mcu is in freeze mode, the input clock to the prescaler is disabled. this feature is useful during emulation as it allows the pwm function to be suspended. in this way, the counters of the pwm can be stopped while in freeze mode so that once normal program ow is continued, the counters are re-enabled to simulate real-time operations. since the registers can still be accessed in this mode, to re-enable the prescaler clock, either disable the pfrz bit or exit freeze mode. 0 allow pwm to continue while in freeze mode. 1 disable pwm input clock to the prescaler whenever the part is in freeze mode. this is useful for emulation.
pulse-width modulator (s12pwm8b8cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 649 read: anytime write: anytime note register bits pclkab0 to pclkab7 can be written anytime. if a clock select is changed while a pwm signal is being generated, a truncated or stretched pulse can occur during the transition. module base + 0x00006 76543210 r pclkab7 pclkab6 pclkab5 pclkab4 pclkab3 pclkab2 pclkab1 pclkab0 w reset 0 0 0 00000 figure 19-9. pwm clock select register (pwmclkab) table 19-11. pwmclk field descriptions note: bits related to available channels have functional signi?ance. writing to unavailable bits has no effect. read from unavailable bits return a zero field description 7 pclkab7 pulse width channel 7 clock a/b select 0 clock b or sb is the clock source for pwm channel 7, as shown in table 19-6 . 1 clock a or sa is the clock source for pwm channel 7, as shown in table 19-6 . 6 pclkab6 pulse width channel 6 clock a/b select 0 clock b or sb is the clock source for pwm channel 6, as shown in table 19-6 . 1 clock a or sa is the clock source for pwm channel 6, as shown in table 19-6 . 5 pclkab5 pulse width channel 5 clock a/b select 0 clock a or sa is the clock source for pwm channel 5, as shown in table 19-5 . 1 clock b or sb is the clock source for pwm channel 5, as shown in table 19-5 . 4 pclkab4 pulse width channel 4 clock a/b select 0 clock a or sa is the clock source for pwm channel 4, as shown in table 19-5 . 1 clock b or sb is the clock source for pwm channel 4, as shown in table 19-5 . 3 pclkab3 pulse width channel 3 clock a/b select 0 clock b or sb is the clock source for pwm channel 3, as shown in table 19-6 . 1 clock a or sa is the clock source for pwm channel 3, as shown in table 19-6 . 2 pclkab2 pulse width channel 2 clock a/b select 0 clock b or sb is the clock source for pwm channel 2, as shown in table 19-6 . 1 clock a or sa is the clock source for pwm channel 2, as shown in table 19-6 . 1 pclkab1 pulse width channel 1 clock a/b select 0 clock a or sa is the clock source for pwm channel 1, as shown in table 19-5 . 1 clock b or sb is the clock source for pwm channel 1, as shown in table 19-5 . 0 pclkab0 pulse width channel 0 clock a/b select 0 clock a or sa is the clock source for pwm channel 0, as shown in table 19-5 . 1 clock b or sb is the clock source for pwm channel 0, as shown in table 19-5 .
pulse-width modulator (s12pwm8b8cv2) mc9s12g family reference manual, rev.1.23 650 freescale semiconductor the clock source of each pwm channel is determined by pclkx bits in pwmclk (see section 19.3.2.3, ?wm clock select register (pwmclk) ) and pclkabx bits in pwmclkab as shown in table 19-5 and table 19-6 . 19.3.2.8 pwm scale a register (pwmscla) pwmscla is the programmable scale value used in scaling clock a to generate clock sa. clock sa is generated by taking clock a, dividing it by the value in the pwmscla register and dividing that by two. clock sa = clock a / (2 * pwmscla) note when pwmscla = $00, pwmscla value is considered a full scale value of 256. clock a is thus divided by 512. any value written to this register will cause the scale counter to load the new scale value (pwmscla). read: anytime write: anytime (causes the scale counter to load the pwmscla value) 19.3.2.9 pwm scale b register (pwmsclb) pwmsclb is the programmable scale value used in scaling clock b to generate clock sb. clock sb is generated by taking clock b, dividing it by the value in the pwmsclb register and dividing that by two. clock sb = clock b / (2 * pwmsclb) note when pwmsclb = $00, pwmsclb value is considered a full scale value of 256. clock b is thus divided by 512. any value written to this register will cause the scale counter to load the new scale value (pwmsclb). read: anytime write: anytime (causes the scale counter to load the pwmsclb value). module base + 0x0008 76543210 r bit 7 6 5 4 3 2 1 bit 0 w reset 0 0 0 00000 figure 19-10. pwm scale a register (pwmscla) module base + 0x0009 76543210 r bit 7 6 5 4 3 2 1 bit 0 w reset 0 0 0 00000 figure 19-11. pwm scale b register (pwmsclb)
pulse-width modulator (s12pwm8b8cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 651 19.3.2.10 pwm channel counter registers (pwmcntx) each channel has a dedicated 8-bit up/down counter which runs at the rate of the selected clock source. the counter can be read at any time without affecting the count or the operation of the pwm channel. in left aligned output mode, the counter counts from 0 to the value in the period register - 1. in center aligned output mode, the counter counts from 0 up to the value in the period register and then back down to 0. any value written to the counter causes the counter to reset to $00, the counter direction to be set to up, the immediate load of both duty and period registers with values from the buffers, and the output to change according to the polarity bit. the counter is also cleared at the end of the effective period (see section 19.4.2.5, ?eft aligned outputs and section 19.4.2.6, ?enter aligned outputs for more details). when the channel is disabled (pwmex = 0), the pwmcntx register does not count. when a channel becomes enabled (pwmex = 1), the associated pwm counter starts at the count in the pwmcntx register. for more detailed information on the operation of the counters, see section 19.4.2.4, ?wm timer counters . in concatenated mode, writes to the 16-bit counter by using a 16-bit access or writes to either the low or high order byte of the counter will reset the 16-bit counter. reads of the 16-bit counter must be made by 16-bit access to maintain data coherency. note writing to the counter while the channel is enabled can cause an irregular pwm cycle to occur. 1 this register is available only when the corresponding channel exists and is reserved if that channel does not exist. writes to a reserved register have no functional effect. reads from a reserved register return zeroes. read: anytime write: anytime (any value written causes pwm counter to be reset to $00). 19.3.2.11 pwm channel period registers (pwmperx) there is a dedicated period register for each channel. the value in this register determines the period of the associated pwm channel. the period registers for each channel are double buffered so that if they change while the channel is enabled, the change will not take effect until one of the following occurs: the effective period ends module base + 0x000c = pwmcnt0, 0x000d = pwmcnt1, 0x000e = pwmcnt2, 0x000f = pwmcnt3 module base + 0x0010 = pwmcnt4, 0x0011 = pwmcnt5, 0x0012 = pwmcnt6, 0x0013 = pwmcnt7 76543210 r bit 7 6 5 4 3 2 1 bit 0 w00000000 reset 0 0 0 00000 figure 19-12. pwm channel counter registers (pwmcntx)
pulse-width modulator (s12pwm8b8cv2) mc9s12g family reference manual, rev.1.23 652 freescale semiconductor the counter is written (counter resets to $00) the channel is disabled in this way, the output of the pwm will always be either the old waveform or the new waveform, not some variation in between. if the channel is not enabled, then writes to the period register will go directly to the latches as well as the buffer. note reads of this register return the most recent value written. reads do not necessarily return the value of the currently active period due to the double buffering scheme. see section 19.4.2.3, ?wm period and duty for more information. to calculate the output period, take the selected clock source period for the channel of interest (a, b, sa, or sb) and multiply it by the value in the period register for that channel: left aligned output (caex = 0) pwmx period = channel clock period * pwmperx center aligned output (caex = 1) pwmx period = channel clock period * (2 * pwmperx) for boundary case programming values, please refer to section 19.4.2.8, ?wm boundary cases . 1 this register is available only when the corresponding channel exists and is reserved if that channel does not exist. writes to a reserved register have no functional effect. reads from a reserved register return zeroes. read: anytime write: anytime 19.3.2.12 pwm channel duty registers (pwmdtyx) there is a dedicated duty register for each channel. the value in this register determines the duty of the associated pwm channel. the duty value is compared to the counter and if it is equal to the counter value a match occurs and the output changes state. the duty registers for each channel are double buffered so that if they change while the channel is enabled, the change will not take effect until one of the following occurs: the effective period ends the counter is written (counter resets to $00) module base + 0x0014 = pwmper0, 0x0015 = pwmper1, 0x0016 = pwmper2, 0x0017 = pwmper3 module base + 0x0018 = pwmper4, 0x0019 = pwmper5, 0x001a = pwmper6, 0x001b = pwmper7 76543210 r bit 7 6 5 4 3 2 1 bit 0 w reset 1 1 1 11111 figure 19-13. pwm channel period registers (pwmperx)
pulse-width modulator (s12pwm8b8cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 653 the channel is disabled in this way, the output of the pwm will always be either the old duty waveform or the new duty waveform, not some variation in between. if the channel is not enabled, then writes to the duty register will go directly to the latches as well as the buffer. note reads of this register return the most recent value written. reads do not necessarily return the value of the currently active duty due to the double buffering scheme. see section 19.4.2.3, ?wm period and duty for more information. note depending on the polarity bit, the duty registers will contain the count of either the high time or the low time. if the polarity bit is one, the output starts high and then goes low when the duty count is reached, so the duty registers contain a count of the high time. if the polarity bit is zero, the output starts low and then goes high when the duty count is reached, so the duty registers contain a count of the low time. to calculate the output duty cycle (high time as a% of period) for a particular channel: polarity = 0 (ppol x =0) duty cycle = [(pwmperx-pwmdtyx)/pwmperx] * 100% polarity = 1 (ppolx = 1) duty cycle = [pwmdtyx / pwmperx] * 100% for boundary case programming values, please refer to section 19.4.2.8, ?wm boundary cases . 1 this register is available only when the corresponding channel exists and is reserved if that channel does not exist. writes to a reserved register have no functional effect. reads from a reserved register return zeroes. read: anytime write: anytime module base + 0x001c = pwmdty0, 0x001d = pwmdty1, 0x001e = pwmdty2, 0x001f = pwmdty3 module base + 0x0020 = pwmdty4, 0x0021 = pwmdty5, 0x0022 = pwmdty6, 0x0023 = pwmdty7 76543210 r bit 7 6 5 4 3 2 1 bit 0 w reset 1 1 1 11111 figure 19-14. pwm channel duty registers (pwmdtyx)
pulse-width modulator (s12pwm8b8cv2) mc9s12g family reference manual, rev.1.23 654 freescale semiconductor 19.4 functional description 19.4.1 pwm clock select there are four available clocks: clock a, clock b, clock sa (scaled a), and clock sb (scaled b). these four clocks are based on the bus clock. clock a and b can be software selected to be 1, 1/2, 1/4, 1/8,..., 1/64, 1/128 times the bus clock. clock sa uses clock a as an input and divides it further with a reloadable counter. similarly, clock sb uses clock b as an input and divides it further with a reloadable counter. the rates available for clock sa are software selectable to be clock a divided by 2, 4, 6, 8,..., or 512 in increments of divide by 2. similar rates are available for clock sb. each pwm channel has the capability of selecting one of four clocks, clock a, clock b, clock sa or clock sb. the block diagram in figure 19-15 shows the four different clocks and how the scaled clocks are created. 19.4.1.1 prescale the input clock to the pwm prescaler is the bus clock. it can be disabled whenever the part is in freeze mode by setting the pfrz bit in the pwmctl register. if this bit is set, whenever the mcu is in freeze mode (freeze mode signal active) the input clock to the prescaler is disabled. this is useful for emulation in order to freeze the pwm. the input clock can also be disabled when all available pwm channels are disabled (pwmex-0 = 0). this is useful for reducing power by disabling the prescale counter. clock a and clock b are scaled values of the input clock. the value is software selectable for both clock a and clock b and has options of 1, 1/2, 1/4, 1/8, 1/16, 1/32, 1/64, or 1/128 times the bus clock. the value selected for clock a is determined by the pcka2, pcka1, pcka0 bits in the pwmprclk register. the value selected for clock b is determined by the pckb2, pckb1, pckb0 bits also in the pwmprclk register. 19.4.1.2 clock scale the scaled a clock uses clock a as an input and divides it further with a user programmable value and then divides this by 2. the scaled b clock uses clock b as an input and divides it further with a user programmable value and then divides this by 2. the rates available for clock sa are software selectable to be clock a divided by 2, 4, 6, 8,..., or 512 in increments of divide by 2. similar rates are available for clock sb.
pulse-width modulator (s12pwm8b8cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 655 figure 19-15. pwm clock select block diagram 128 2 4 8 16 32 64 pckb2 pckb1 pckb0 m u x clock a clock b clock sa clock a/2, a/4, a/6,....a/512 prescale scale divide by pfrz freeze mode signal bus clock clock select m u x clock to pwm ch 0 m u x clock to pwm ch 2 m u x clock to pwm ch 1 m u x clock to pwm ch 4 m u x clock to pwm ch 5 m u x clock to pwm ch 6 m u x clock to pwm ch 7 m u x clock to pwm ch 3 load div 2 pwmsclb clock sb clock b/2, b/4, b/6,....b/512 m u x pcka2 pcka1 pcka0 pwme7-0 count = 1 load div 2 pwmscla count = 1 8-bit down counter 8-bit down counter prescaler taps: maximum possible channels, scalable in pairs from pwm0 to pwm7. pclk0 pclkab0 pclk1 pclkab1 pclk7 pclkab7 pclk6 pclkab6 pclk5 pclkab5 pclk4 pclkab4 pclk3 pclkab3 pclk2 pclkab2
pulse-width modulator (s12pwm8b8cv2) mc9s12g family reference manual, rev.1.23 656 freescale semiconductor clock a is used as an input to an 8-bit down counter. this down counter loads a user programmable scale value from the scale register (pwmscla). when the down counter reaches one, a pulse is output and the 8-bit counter is re-loaded. the output signal from this circuit is further divided by two. this gives a greater range with only a slight reduction in granularity. clock sa equals clock a divided by two times the value in the pwmscla register. note clock sa = clock a / (2 * pwmscla) when pwmscla = $00, pwmscla value is considered a full scale value of 256. clock a is thus divided by 512. similarly, clock b is used as an input to an 8-bit down counter followed by a divide by two producing clock sb. thus, clock sb equals clock b divided by two times the value in the pwmsclb register. note clock sb = clock b / (2 * pwmsclb) when pwmsclb = $00, pwmsclb value is considered a full scale value of 256. clock b is thus divided by 512. as an example, consider the case in which the user writes $ff into the pwmscla register. clock a for this case will be e (bus clock) divided by 4. a pulse will occur at a rate of once every 255x4 e cycles. passing this through the divide by two circuit produces a clock signal at an e divided by 2040 rate. similarly, a value of $01 in the pwmscla register when clock a is e divided by 4 will produce a clock at an e divided by 8 rate. writing to pwmscla or pwmsclb causes the associated 8-bit down counter to be re-loaded. otherwise, when changing rates the counter would have to count down to $01 before counting at the proper rate. forcing the associated counter to re-load the scale register value every time pwmscla or pwmsclb is written prevents this. note writing to the scale registers while channels are operating can cause irregularities in the pwm outputs. 19.4.1.3 clock select each pwm channel has the capability of selecting one of four clocks, clock a, clock sa, clock b or clock sb. the clock selection is done with the pclkx control bits in the pwmclk register and pclkabx control bits in pwmclkab register. for backward compatibility consideration, the reset value of pwmclk and pwmclkab con?ures following default clock selection. for channels 0, 1, 4, and 5 the clock choices are clock a. for channels 2, 3, 6, and 7 the clock choices are clock b. note changing clock control bits while channels are operating can cause irregularities in the pwm outputs.
pulse-width modulator (s12pwm8b8cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 657 19.4.2 pwm channel timers the main part of the pwm module are the actual timers. each of the timer channels has a counter, a period register and a duty register (each are 8-bit). the waveform output period is controlled by a match between the period register and the value in the counter. the duty is controlled by a match between the duty register and the counter value and causes the state of the output to change during the period. the starting polarity of the output is also selectable on a per channel basis. shown below in figure 19-16 is the block diagram for the pwm timer. figure 19-16. pwm timer channel block diagram 19.4.2.1 pwm enable each pwm channel has an enable bit (pwmex) to start its waveform output. when any of the pwmex bits are set (pwmex = 1), the associated pwm output signal is enabled immediately. however, the actual pwm waveform is not available on the associated pwm output until its clock source begins its next cycle due to the synchronization of pwmex and the clock source. an exception to this is when channels are concatenated. refer to section 19.4.2.7, ?wm 16-bit functions for more detail. note the ?st pwm cycle after enabling the channel can be irregular. clock source t r q q ppolx from port pwmp data register pwmex to pin driver gate 8-bit compare = pwmdtyx 8-bit compare = pwmperx caex t r q q 8-bit counter pwmcntx m u x m u x (clock edge sync) up/down reset
pulse-width modulator (s12pwm8b8cv2) mc9s12g family reference manual, rev.1.23 658 freescale semiconductor on the front end of the pwm timer, the clock is enabled to the pwm circuit by the pwmex bit being high. there is an edge-synchronizing circuit to guarantee that the clock will only be enabled or disabled at an edge. when the channel is disabled (pwmex = 0), the counter for the channel does not count. 19.4.2.2 pwm polarity each channel has a polarity bit to allow starting a waveform cycle with a high or low signal. this is shown on the block diagram figure 19-16 as a mux select of either the q output or the q output of the pwm output ?p ?p. when one of the bits in the pwmpol register is set, the associated pwm channel output is high at the beginning of the waveform, then goes low when the duty count is reached. conversely, if the polarity bit is zero, the output starts low and then goes high when the duty count is reached. 19.4.2.3 pwm period and duty dedicated period and duty registers exist for each channel and are double buffered so that if they change while the channel is enabled, the change will not take effect until one of the following occurs: the effective period ends the counter is written (counter resets to $00) the channel is disabled in this way, the output of the pwm will always be either the old waveform or the new waveform, not some variation in between. if the channel is not enabled, then writes to the period and duty registers will go directly to the latches as well as the buffer. a change in duty or period can be forced into effect ?mmediately?by writing the new value to the duty and/or period registers and then writing to the counter. this forces the counter to reset and the new duty and/or period values to be latched. in addition, since the counter is readable, it is possible to know where the count is with respect to the duty value and software can be used to make adjustments note when forcing a new period or duty into effect immediately, an irregular pwm cycle can occur. depending on the polarity bit, the duty registers will contain the count of either the high time or the low time. 19.4.2.4 pwm timer counters each channel has a dedicated 8-bit up/down counter which runs at the rate of the selected clock source (see section 19.4.1, ?wm clock select for the available clock sources and rates). the counter compares to two registers, a duty register and a period register as shown in figure 19-16 . when the pwm counter matches the duty register, the output ?p-?p changes state, causing the pwm waveform to also change state. a match between the pwm counter and the period register behaves differently depending on what output mode is selected as shown in figure 19-16 and described in section 19.4.2.5, ?eft aligned outputs and section 19.4.2.6, ?enter aligned outputs .
pulse-width modulator (s12pwm8b8cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 659 each channel counter can be read at anytime without affecting the count or the operation of the pwm channel. any value written to the counter causes the counter to reset to $00, the counter direction to be set to up, the immediate load of both duty and period registers with values from the buffers, and the output to change according to the polarity bit. when the channel is disabled (pwmex = 0), the counter stops. when a channel becomes enabled (pwmex = 1), the associated pwm counter continues from the count in the pwmcntx register. this allows the waveform to continue where it left off when the channel is re-enabled. when the channel is disabled, writing ? to the period register will cause the counter to reset on the next selected clock. note if the user wants to start a new ?lean?pwm waveform without any ?istory?from the old waveform, the user must write to channel counter (pwmcntx) prior to enabling the pwm channel (pwmex = 1). generally, writes to the counter are done prior to enabling a channel in order to start from a known state. however, writing a counter can also be done while the pwm channel is enabled (counting). the effect is similar to writing the counter when the channel is disabled, except that the new period is started immediately with the output set according to the polarity bit. note writing to the counter while the channel is enabled can cause an irregular pwm cycle to occur. the counter is cleared at the end of the effective period (see section 19.4.2.5, ?eft aligned outputs and section 19.4.2.6, ?enter aligned outputs for more details). 19.4.2.5 left aligned outputs the pwm timer provides the choice of two types of outputs, left aligned or center aligned. they are selected with the caex bits in the pwmcae register. if the caex bit is cleared (caex = 0), the corresponding pwm output will be left aligned. in left aligned output mode, the 8-bit counter is con?ured as an up counter only. it compares to two registers, a duty register and a period register as shown in the block diagram in figure 19-16 . when the pwm counter matches the duty register the output ?p-?p changes state causing the pwm waveform to also change state. a match between the pwm counter and the period register resets the counter and the output ?p-?p, as shown in figure 19-16 , as well as performing a load from the double buffer period and duty register to the associated registers, as described in section 19.4.2.3, ?wm period and duty . the counter counts from 0 to the value in the period register ?1. table 19-12. pwm timer counter conditions counter clears ($00) counter counts counter stops when pwmcntx register written to any value when pwm channel is enabled (pwmex = 1). counts from last value in pwmcntx. when pwm channel is disabled (pwmex = 0) effective period ends
pulse-width modulator (s12pwm8b8cv2) mc9s12g family reference manual, rev.1.23 660 freescale semiconductor note changing the pwm output mode from left aligned to center aligned output (or vice versa) while channels are operating can cause irregularities in the pwm output. it is recommended to program the output mode before enabling the pwm channel. figure 19-17. pwm left aligned output waveform to calculate the output frequency in left aligned output mode for a particular channel, take the selected clock source frequency for the channel (a, b, sa, or sb) and divide it by the value in the period register for that channel. pwmx frequency = clock (a, b, sa, or sb) / pwmperx pwmx duty cycle (high time as a% of period): polarity = 0 (ppolx = 0) duty cycle = [(pwmperx-pwmdtyx)/pwmperx] * 100% polarity = 1 (ppolx = 1) duty cycle = [pwmdtyx / pwmperx] * 100% as an example of a left aligned output, consider the following case: clock source = e, where e = 10 mhz (100 ns period) ppolx = 0 pwmperx = 4 pwmdtyx = 1 pwmx frequency = 10 mhz/4 = 2.5 mhz pwmx period = 400 ns pwmx duty cycle = 3/4 *100% = 75% the output waveform generated is shown in figure 19-18 . figure 19-18. pwm left aligned output example waveform pwmdtyx period = pwmperx ppolx = 0 ppolx = 1 period = 400 ns e = 100 ns duty cycle = 75%
pulse-width modulator (s12pwm8b8cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 661 19.4.2.6 center aligned outputs for center aligned output mode selection, set the caex bit (caex = 1) in the pwmcae register and the corresponding pwm output will be center aligned. the 8-bit counter operates as an up/down counter in this mode and is set to up whenever the counter is equal to $00. the counter compares to two registers, a duty register and a period register as shown in the block diagram in figure 19-16 . when the pwm counter matches the duty register, the output ?p-?p changes state, causing the pwm waveform to also change state. a match between the pwm counter and the period register changes the counter direction from an up-count to a down-count. when the pwm counter decrements and matches the duty register again, the output ?p-?p changes state causing the pwm output to also change state. when the pwm counter decrements and reaches zero, the counter direction changes from a down-count back to an up-count and a load from the double buffer period and duty registers to the associated registers is performed, as described in section 19.4.2.3, ?wm period and duty . the counter counts from 0 up to the value in the period register and then back down to 0. thus the effective period is pwmperx*2. note changing the pwm output mode from left aligned to center aligned output (or vice versa) while channels are operating can cause irregularities in the pwm output. it is recommended to program the output mode before enabling the pwm channel. figure 19-19. pwm center aligned output waveform to calculate the output frequency in center aligned output mode for a particular channel, take the selected clock source frequency for the channel (a, b, sa, or sb) and divide it by twice the value in the period register for that channel. pwmx frequency = clock (a, b, sa, or sb) / (2*pwmperx) pwmx duty cycle (high time as a% of period): polarity = 0 (ppolx = 0) duty cycle = [(pwmperx-pwmdtyx)/pwmperx] * 100% polarity = 1 (ppolx = 1) duty cycle = [pwmdtyx / pwmperx] * 100% as an example of a center aligned output, consider the following case: ppolx = 0 ppolx = 1 pwmdtyx pwmdtyx period = pwmperx*2 pwmperx pwmperx
pulse-width modulator (s12pwm8b8cv2) mc9s12g family reference manual, rev.1.23 662 freescale semiconductor clock source = e, where e = 10 mhz (100 ns period) ppolx = 0 pwmperx = 4 pwmdtyx = 1 pwmx frequency = 10 mhz/8 = 1.25 mhz pwmx period = 800 ns pwmx duty cycle = 3/4 *100% = 75% shown in figure 19-20 is the output waveform generated. figure 19-20. pwm center aligned output example waveform 19.4.2.7 pwm 16-bit functions the scalable pwm timer also has the option of generating up to 8-channels of 8-bits or 4-channels of 16-bits for greater pwm resolution. this 16-bit channel option is achieved through the concatenation of two 8-bit channels. the pwmctl register contains four control bits, each of which is used to concatenate a pair of pwm channels into one 16-bit channel. channels 6 and 7 are concatenated with the con67 bit, channels 4 and 5 are concatenated with the con45 bit, channels 2 and 3 are concatenated with the con23 bit, and channels 0 and 1 are concatenated with the con01 bit. note change these bits only when both corresponding channels are disabled. when channels 6 and 7 are concatenated, channel 6 registers become the high order bytes of the double byte channel, as shown in figure 19-21 . similarly, when channels 4 and 5 are concatenated, channel 4 registers become the high order bytes of the double byte channel. when channels 2 and 3 are concatenated, channel 2 registers become the high order bytes of the double byte channel. when channels 0 and 1 are concatenated, channel 0 registers become the high order bytes of the double byte channel. when using the 16-bit concatenated mode, the clock source is determined by the low order 8-bit channel clock select control bits. that is channel 7 when channels 6 and 7 are concatenated, channel 5 when channels 4 and 5 are concatenated, channel 3 when channels 2 and 3 are concatenated, and channel 1 when channels 0 and 1 are concatenated. the resulting pwm is output to the pins of the corresponding low order 8-bit channel as also shown in figure 19-21 . the polarity of the resulting pwm output is controlled by the ppolx bit of the corresponding low order 8-bit channel as well. e = 100 ns duty cycle = 75% e = 100 ns period = 800 ns
pulse-width modulator (s12pwm8b8cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 663 figure 19-21. pwm 16-bit mode once concatenated mode is enabled (conxx bits set in pwmctl register), enabling/disabling the corresponding 16-bit pwm channel is controlled by the low order pwmex bit. in this case, the high order bytes pwmex bits have no effect and their corresponding pwm output is disabled. pwmcnt6 pwmcnt7 pwm7 clock source 7 high low period/duty compare pwmcnt4 pwmcnt5 pwm5 clock source 5 high low period/duty compare pwmcnt2 pwmcnt3 pwm3 clock source 3 high low period/duty compare pwmcnt0 pwmcnt1 pwm1 clock source 1 high low period/duty compare maximum possible 16-bit channels
pulse-width modulator (s12pwm8b8cv2) mc9s12g family reference manual, rev.1.23 664 freescale semiconductor in concatenated mode, writes to the 16-bit counter by using a 16-bit access or writes to either the low or high order byte of the counter will reset the 16-bit counter. reads of the 16-bit counter must be made by 16-bit access to maintain data coherency. either left aligned or center aligned output mode can be used in concatenated mode and is controlled by the low order caex bit. the high order caex bit has no effect. table 19-13 is used to summarize which channels are used to set the various control bits when in 16-bit mode. 19.4.2.8 pwm boundary cases table 19-14 summarizes the boundary conditions for the pwm regardless of the output mode (left aligned or center aligned) and 8-bit (normal) or 16-bit (concatenation). 19.5 resets the reset state of each individual bit is listed within the section 19.3.2, ?egister descriptions which details the registers and their bit-?lds. all special functions or modes which are initialized during or just following reset are described within this section. the 8-bit up/down counter is con?ured as an up counter out of reset. all the channels are disabled and all the counters do not count. table 19-13. 16-bit concatenation mode summary note: bits related to available channels have functional signi?ance. conxx pwmex ppolx pclkx caex pwmx output con67 pwme7 ppol7 pclk7 cae7 pwm7 con45 pwme5 ppol5 pclk5 cae5 pwm5 con23 pwme3 ppol3 pclk3 cae3 pwm3 con01 pwme1 ppol1 pclk1 cae1 pwm1 table 19-14. pwm boundary cases pwmdtyx pwmperx ppolx pwmx output $00 (indicates no duty) >$00 1 always low $00 (indicates no duty) >$00 0 always high xx $00 1 (indicates no period) 1 counter = $00 and does not count. 1 always high xx $00 1 (indicates no period) 0 always low >= pwmperx xx 1 always high >= pwmperx xx 0 always low
pulse-width modulator (s12pwm8b8cv2) mc9s12g family reference manual, rev.1.23 freescale semiconductor 665 for channels 0, 1, 4, and 5 the clock choices are clock a. for channels 2, 3, 6, and 7 the clock choices are clock b. 19.6 interrupts the pwm module has no interrupt.
pulse-width modulator (s12pwm8b8cv2) mc9s12g family reference manual, rev.1.23 666 freescale semiconductor
mc9s12g family reference manual, rev.1.23 freescale semiconductor 667 chapter 20 serial communication interface (s12sciv5) 20.1 introduction this block guide provides an overview of the serial communication interface (sci) module. the sci allows asynchronous serial communications with peripheral devices and other cpus. 20.1.1 glossary ir: infrared irda: infrared design associate irq: interrupt request lin: local interconnect network lsb: least signi?ant bit msb: most signi?ant bit nrz: non-return-to-zero rzi: return-to-zero-inverted rxd: receive pin sci : serial communication interface txd: transmit pin table 20-1. revision history version number revision date effective date author description of changes 05.03 12/25/2008 remove redundancy comments in figure1-2 05.04 08/05/2009 fix typo, scibdl reset value be 0x04, not 0x00 05.05 06/03/2010 fix typo, table 20-4 ,scicr1 even parity should be pt=0 fix typo, on page 20-688 ,should be bkdif,not bldif
serial communication interface (s12sciv5) mc9s12g family reference manual, rev.1.23 668 freescale semiconductor 20.1.2 features the sci includes these distinctive features: full-duplex or single-wire operation standard mark/space non-return-to-zero (nrz) format selectable irda 1.4 return-to-zero-inverted (rzi) format with programmable pulse widths 13-bit baud rate selection programmable 8-bit or 9-bit data format separately enabled transmitter and receiver programmable polarity for transmitter and receiver programmable transmitter output parity two receiver wakeup methods: idle line wakeup address mark wakeup interrupt-driven operation with eight ?gs: transmitter empty transmission complete receiver full idle receiver input receiver overrun noise error framing error parity error receive wakeup on active edge transmit collision detect supporting lin break detect supporting lin receiver framing error detection hardware parity checking 1/16 bit-time noise detection 20.1.3 modes of operation the sci functions the same in normal, special, and emulation modes. it has two low power modes, wait and stop modes. run mode wait mode stop mode
serial communication interface (s12sciv5) mc9s12g family reference manual, rev.1.23 freescale semiconductor 669 20.1.4 block diagram figure 20-1 is a high level block diagram of the sci module, showing the interaction of various function blocks. figure 20-1. sci block diagram 20.2 external signal description the sci module has a total of two external pins. 20.2.1 txd ?transmit pin the txd pin transmits sci (standard or infrared) data. it will idle high in either mode and is high impedance anytime the transmitter is disabled. 20.2.2 rxd ?receive pin the rxd pin receives sci (standard or infrared) data. an idle line is detected as a line high. this input is ignored when the receiver is disabled and should be terminated to a known voltage. 20.3 memory map and register de?ition this section provides a detailed description of all the sci registers. sci data register rxd data in data out txd receive shift register infrared decoder receive & wakeup control data format control transmit control baud rate generator bus clock 1/16 transmit shift register sci data register receive interrupt generation transmit interrupt generation infrared encoder idle rdrf/or tc tdre brkd berr rxedg sci interrupt request
serial communication interface (s12sciv5) mc9s12g family reference manual, rev.1.23 670 freescale semiconductor 20.3.1 module memory map and register de?ition the memory map for the sci module is given below in figure 20-2 . the address listed for each register is the address offset. the total address for each register is the sum of the base address for the sci module and the address offset for each register. 20.3.2 register descriptions this section consists of register descriptions in address order. each description includes a standard register diagram with an associated ?ure number. writes to a reserved register locations do not have any effect and reads of these locations return a zero. details of register bit and ?ld function follow the register diagrams, in bit order. register name bit 7 6 5 4 3 2 1 bit 0 0x0000 scibdh 1 r iren tnp1 tnp0 sbr12 sbr11 sbr10 sbr9 sbr8 w 0x0001 scibdl 1 r sbr7 sbr6 sbr5 sbr4 sbr3 sbr2 sbr1 sbr0 w 0x0002 scicr1 1 r loops sciswai rsrc m wake ilt pe pt w 0x0000 sciasr1 2 r rxedgif 0000 berrv berrif bkdif w 0x0001 sciacr1 2 r rxedgie 00000 berrie bkdie w 0x0002 sciacr2 2 r00000 berrm1 berrm0 bkdfe w 0x0003 scicr2 r tie tcie rie ilie te re rwu sbk w 0x0004 scisr1 r tdre tc rdrf idle or nf fe pf w 0x0005 scisr2 r amap 00 txpol rxpol brk13 txdir raf w = unimplemented or reserved figure 20-2. sci register summary (sheet 1 of 2)
serial communication interface (s12sciv5) mc9s12g family reference manual, rev.1.23 freescale semiconductor 671 20.3.2.1 sci baud rate registers (scibdh, scibdl) read: anytime, if amap = 0. if only scibdh is written to, a read will not return the correct data until scibdl is written to as well, following a write to scibdh. write: anytime, if amap = 0. note those two registers are only visible in the memory map if amap = 0 (reset condition). the sci baud rate register is used by to determine the baud rate of the sci, and to control the infrared modulation/demodulation submodule. 0x0006 scidrh rr8 t8 000000 w 0x0007 scidrl rr7r6r5r4r3r2r1r0 wt7t6t5t4t3t2t1t0 1.these registers are accessible if the amap bit in the scisr2 register is set to zero. 2,these registers are accessible if the amap bit in the scisr2 register is set to one. module base + 0x0000 76543210 r iren tnp1 tnp0 sbr12 sbr11 sbr10 sbr9 sbr8 w reset 0 0 0 00000 figure 20-3. sci baud rate register (scibdh) module base + 0x0001 76543210 r sbr7 sbr6 sbr5 sbr4 sbr3 sbr2 sbr1 sbr0 w reset 0 0 0 00100 figure 20-4. sci baud rate register (scibdl) register name bit 7 6 5 4 3 2 1 bit 0 = unimplemented or reserved figure 20-2. sci register summary (sheet 2 of 2)
serial communication interface (s12sciv5) mc9s12g family reference manual, rev.1.23 672 freescale semiconductor 20.3.2.2 sci control register 1 (scicr1) read: anytime, if amap = 0. write: anytime, if amap = 0. note this register is only visible in the memory map if amap = 0 (reset condition). table 20-2. scibdh and scibdl field descriptions field description 7 iren infrared enable bit ?this bit enables/disables the infrared modulation/demodulation submodule. 0 ir disabled 1 ir enabled 6:5 tnp[1:0] transmitter narrow pulse bits these bits enable whether the sci transmits a 1/16, 3/16, 1/32 or 1/4 narrow pulse. see table 20-3 . 4:0 7:0 sbr[12:0] sci baud rate bits ?the baud rate for the sci is determined by the bits in this register. the baud rate is calculated two different ways depending on the state of the iren bit. the formulas for calculating the baud rate are: when iren = 0 then, sci baud rate = sci bus clock / (16 x sbr[12:0]) when iren = 1 then, sci baud rate = sci bus clock / (32 x sbr[12:1]) note: the baud rate generator is disabled after reset and not started until the te bit or the re bit is set for the ?st time. the baud rate generator is disabled when (sbr[12:0] = 0 and iren = 0) or (sbr[12:1] = 0 and iren = 1). note: writing to scibdh has no effect without writing to scibdl, because writing to scibdh puts the data in a temporary location until scibdl is written to. table 20-3. irsci transmit pulse width tnp[1:0] narrow pulse width 11 1/4 10 1/32 01 1/16 00 3/16 module base + 0x0002 76543210 r loops sciswai rsrc m wake ilt pe pt w reset 0 0 0 00000 figure 20-5. sci control register 1 (scicr1)
serial communication interface (s12sciv5) mc9s12g family reference manual, rev.1.23 freescale semiconductor 673 table 20-4. scicr1 field descriptions field description 7 loops loop select bit loops enables loop operation. in loop operation, the rxd pin is disconnected from the sci and the transmitter output is internally connected to the receiver input. both the transmitter and the receiver must be enabled to use the loop function. 0 normal operation enabled 1 loop operation enabled the receiver input is determined by the rsrc bit. 6 sciswai sci stop in wait mode bit ?sciswai disables the sci in wait mode. 0 sci enabled in wait mode 1 sci disabled in wait mode 5 rsrc receiver source bit ?when loops = 1, the rsrc bit determines the source for the receiver shift register input. see table 20-5 . 0 receiver input internally connected to transmitter output 1 receiver input connected externally to transmitter 4 m data format mode bit ?mode determines whether data characters are eight or nine bits long. 0 one start bit, eight data bits, one stop bit 1 one start bit, nine data bits, one stop bit 3 wake wakeup condition bit wake determines which condition wakes up the sci: a logic 1 (address mark) in the most signi?ant bit position of a received data character or an idle condition on the rxd pin. 0 idle line wakeup 1 address mark wakeup 2 ilt idle line type bit ?ilt determines when the receiver starts counting logic 1s as idle character bits. the counting begins either after the start bit or after the stop bit. if the count begins after the start bit, then a string of logic 1s preceding the stop bit may cause false recognition of an idle character. beginning the count after the stop bit avoids false idle character recognition, but requires properly synchronized transmissions. 0 idle character bit count begins after start bit 1 idle character bit count begins after stop bit 1 pe parity enable bit pe enables the parity function. when enabled, the parity function inserts a parity bit in the most signi?ant bit position. 0 parity function disabled 1 parity function enabled 0 pt parity type bit pt determines whether the sci generates and checks for even parity or odd parity. with even parity, an even number of 1s clears the parity bit and an odd number of 1s sets the parity bit. with odd parity, an odd number of 1s clears the parity bit and an even number of 1s sets the parity bit. 0 even parity 1 odd parity table 20-5. loop functions loops rsrc function 0 x normal operation 1 0 loop mode with transmitter output internally connected to receiver input 1 1 single-wire mode with txd pin connected to receiver input
serial communication interface (s12sciv5) mc9s12g family reference manual, rev.1.23 674 freescale semiconductor 20.3.2.3 sci alternative status register 1 (sciasr1) read: anytime, if amap = 1 write: anytime, if amap = 1 20.3.2.4 sci alternative control register 1 (sciacr1) read: anytime, if amap = 1 write: anytime, if amap = 1 module base + 0x0000 76543210 r rxedgif 0 0 0 0 berrv berrif bkdif w reset 0 0 0 00000 = unimplemented or reserved figure 20-6. sci alternative status register 1 (sciasr1) table 20-6. sciasr1 field descriptions field description 7 rxedgif receive input active edge interrupt flag ?rxedgif is asserted, if an active edge (falling if rxpol = 0, rising if rxpol = 1) on the rxd input occurs. rxedgif bit is cleared by writing a ??to it. 0 no active receive on the receive input has occurred 1 an active edge on the receive input has occurred 2 berrv bit error value berrv re?cts the state of the rxd input when the bit error detect circuitry is enabled and a mismatch to the expected value happened. the value is only meaningful, if berrif = 1. 0 a low input was sampled, when a high was expected 1 a high input reassembled, when a low was expected 1 berrif bit error interrupt flag ?berrif is asserted, when the bit error detect circuitry is enabled and if the value sampled at the rxd input does not match the transmitted value. if the berrie interrupt enable bit is set an interrupt will be generated. the berrif bit is cleared by writing a ??to it. 0 no mismatch detected 1 a mismatch has occurred 0 bkdif break detect interrupt flag bkdif is asserted, if the break detect circuitry is enabled and a break signal is received. if the bkdie interrupt enable bit is set an interrupt will be generated. the bkdif bit is cleared by writing a ??to it. 0 no break signal was received 1 a break signal was received module base + 0x0001 76543210 r rxedgie 00000 berrie bkdie w reset 0 0 0 00000 = unimplemented or reserved figure 20-7. sci alternative control register 1 (sciacr1)
serial communication interface (s12sciv5) mc9s12g family reference manual, rev.1.23 freescale semiconductor 675 20.3.2.5 sci alternative control register 2 (sciacr2) read: anytime, if amap = 1 write: anytime, if amap = 1 table 20-7. sciacr1 field descriptions field description 7 rsedgie receive input active edge interrupt enable rxedgie enables the receive input active edge interrupt ?g, rxedgif, to generate interrupt requests. 0 rxedgif interrupt requests disabled 1 rxedgif interrupt requests enabled 1 berrie bit error interrupt enable ?berrie enables the bit error interrupt ?g, berrif, to generate interrupt requests. 0 berrif interrupt requests disabled 1 berrif interrupt requests enabled 0 bkdie break detect interrupt enable ?bkdie enables the break detect interrupt ?g, bkdif, to generate interrupt requests. 0 bkdif interrupt requests disabled 1 bkdif interrupt requests enabled module base + 0x0002 76543210 r00000 berrm1 berrm0 bkdfe w reset 0 0 0 00000 = unimplemented or reserved figure 20-8. sci alternative control register 2 (sciacr2) table 20-8. sciacr2 field descriptions field description 2:1 berrm[1:0] bit error mode ?those two bits determines the functionality of the bit error detect feature. see table 20-9 . 0 bkdfe break detect feature enable ?bkdfe enables the break detect circuitry. 0 break detect circuit disabled 1 break detect circuit enabled table 20-9. bit error mode coding berrm1 berrm0 function 0 0 bit error detect circuit is disabled 0 1 receive input sampling occurs during the 9th time tick of a transmitted bit (refer to figure 20-19 ) 1 0 receive input sampling occurs during the 13th time tick of a transmitted bit (refer to figure 20-19 )
serial communication interface (s12sciv5) mc9s12g family reference manual, rev.1.23 676 freescale semiconductor 20.3.2.6 sci control register 2 (scicr2) read: anytime write: anytime 1 1 reserved module base + 0x0003 76543210 r tie tcie rie ilie te re rwu sbk w reset 0 0 0 00000 figure 20-9. sci control register 2 (scicr2) table 20-10. scicr2 field descriptions field description 7 tie transmitter interrupt enable bit ?tie enables the transmit data register empty ?g, tdre, to generate interrupt requests. 0 tdre interrupt requests disabled 1 tdre interrupt requests enabled 6 tcie transmission complete interrupt enable bit tcie enables the transmission complete ?g, tc, to generate interrupt requests. 0 tc interrupt requests disabled 1 tc interrupt requests enabled 5 rie receiver full interrupt enable bit rie enables the receive data register full ?g, rdrf, or the overrun ?g, or, to generate interrupt requests. 0 rdrf and or interrupt requests disabled 1 rdrf and or interrupt requests enabled 4 ilie idle line interrupt enable bit ?ilie enables the idle line ?g, idle, to generate interrupt requests. 0 idle interrupt requests disabled 1 idle interrupt requests enabled 3 te transmitter enable bit ?te enables the sci transmitter and con?ures the txd pin as being controlled by the sci. the te bit can be used to queue an idle preamble. 0 transmitter disabled 1 transmitter enabled 2 re receiver enable bit ?re enables the sci receiver. 0 receiver disabled 1 receiver enabled table 20-9. bit error mode coding berrm1 berrm0 function
serial communication interface (s12sciv5) mc9s12g family reference manual, rev.1.23 freescale semiconductor 677 20.3.2.7 sci status register 1 (scisr1) the scisr1 and scisr2 registers provides inputs to the mcu for generation of sci interrupts. also, these registers can be polled by the mcu to check the status of these bits. the ?g-clearing procedures require that the status register be read followed by a read or write to the sci data register.it is permissible to execute other instructions between the two steps as long as it does not compromise the handling of i/o, but the order of operations is important for ?g clearing. read: anytime write: has no meaning or effect 1 rwu receiver wakeup bit ?standby state 0 normal operation. 1 rwu enables the wakeup function and inhibits further receiver interrupt requests. normally, hardware wakes the receiver by automatically clearing rwu. 0 sbk send break bit ?toggling sbk sends one break character (10 or 11 logic 0s, respectively 13 or 14 logics 0s if brk13 is set). toggling implies clearing the sbk bit before the break character has ?ished transmitting. as long as sbk is set, the transmitter continues to send complete break characters (10 or 11 bits, respectively 13 or 14 bits). 0 no break characters 1 transmit break characters module base + 0x0004 76543210 r tdre tc rdrf idle or nf fe pf w reset 1 1 0 00000 = unimplemented or reserved figure 20-10. sci status register 1 (scisr1) table 20-10. scicr2 field descriptions (continued) field description
serial communication interface (s12sciv5) mc9s12g family reference manual, rev.1.23 678 freescale semiconductor table 20-11. scisr1 field descriptions field description 7 tdre transmit data register empty flag ?tdre is set when the transmit shift register receives a byte from the sci data register. when tdre is 1, the transmit data register (scidrh/l) is empty and can receive a new value to transmit.clear tdre by reading sci status register 1 (scisr1), with tdre set and then writing to sci data register low (scidrl). 0 no byte transferred to transmit shift register 1 byte transferred to transmit shift register; transmit data register empty 6 tc transmit complete flag tc is set low when there is a transmission in progress or when a preamble or break character is loaded. tc is set high when the tdre ?g is set and no data, preamble, or break character is being transmitted.when tc is set, the txd pin becomes idle (logic 1). clear tc by reading sci status register 1 (scisr1) with tc set and then writing to sci data register low (scidrl). tc is cleared automatically when data, preamble, or break is queued and ready to be sent. tc is cleared in the event of a simultaneous set and clear of the tc ?g (transmission not complete). 0 transmission in progress 1 no transmission in progress 5 rdrf receive data register full flag rdrf is set when the data in the receive shift register transfers to the sci data register. clear rdrf by reading sci status register 1 (scisr1) with rdrf set and then reading sci data register low (scidrl). 0 data not available in sci data register 1 received data available in sci data register 4 idle idle line flag idle is set when 10 consecutive logic 1s (if m = 0) or 11 consecutive logic 1s (if m =1) appear on the receiver input. once the idle ?g is cleared, a valid frame must again set the rdrf ?g before an idle condition can set the idle ?g.clear idle by reading sci status register 1 (scisr1) with idle set and then reading sci data register low (scidrl). 0 receiver input is either active now or has never become active since the idle ?g was last cleared 1 receiver input has become idle note: when the receiver wakeup bit (rwu) is set, an idle line condition does not set the idle ?g. 3 or overrun flag ?or is set when software fails to read the sci data register before the receive shift register receives the next frame. the or bit is set immediately after the stop bit has been completely received for the second frame. the data in the shift register is lost, but the data already in the sci data registers is not affected. clear or by reading sci status register 1 (scisr1) with or set and then reading sci data register low (scidrl). 0 no overrun 1 overrun note: or ?g may read back as set when rdrf ?g is clear. this may happen if the following sequence of events occurs: 1. after the ?st frame is received, read status register scisr1 (returns rdrf set and or ?g clear); 2. receive second frame without reading the ?st frame in the data register (the second frame is not received and or ?g is set); 3. read data register scidrl (returns ?st frame and clears rdrf ?g in the status register); 4. read status register scisr1 (returns rdrf clear and or set). event 3 may be at exactly the same time as event 2 or any time after. when this happens, a dummy scidrl read following event 4 will be required to clear the or ?g if further frames are to be received. 2 nf noise flag nf is set when the sci detects noise on the receiver input. nf bit is set during the same cycle as the rdrf ?g but does not get set in the case of an overrun. clear nf by reading sci status register 1(scisr1), and then reading sci data register low (scidrl). 0 no noise 1 noise
serial communication interface (s12sciv5) mc9s12g family reference manual, rev.1.23 freescale semiconductor 679 20.3.2.8 sci status register 2 (scisr2) read: anytime write: anytime 1 fe framing error flag fe is set when a logic 0 is accepted as the stop bit. fe bit is set during the same cycle as the rdrf ?g but does not get set in the case of an overrun. fe inhibits further data reception until it is cleared. clear fe by reading sci status register 1 (scisr1) with fe set and then reading the sci data register low (scidrl). 0 no framing error 1 framing error 0 pf parity error flag pf is set when the parity enable bit (pe) is set and the parity of the received data does not match the parity type bit (pt). pf bit is set during the same cycle as the rdrf ?g but does not get set in the case of an overrun. clear pf by reading sci status register 1 (scisr1), and then reading sci data register low (scidrl). 0 no parity error 1 parity error module base + 0x0005 76543210 r amap 00 txpol rxpol brk13 txdir raf w reset 0 0 0 00000 = unimplemented or reserved figure 20-11. sci status register 2 (scisr2) table 20-12. scisr2 field descriptions field description 7 amap alternative map this bit controls which registers sharing the same address space are accessible. in the reset condition the sci behaves as previous versions. setting amap=1 allows the access to another set of control and status registers and hides the baud rate and sci control register 1. 0 the registers labelled scibdh (0x0000),scibdl (0x0001), scicr1 (0x0002) are accessible 1 the registers labelled sciasr1 (0x0000),sciacr1 (0x0001), sciacr2 (0x00002) are accessible 4 txpol transmit polarity this bit control the polarity of the transmitted data. in nrz format, a one is represented by a mark and a zero is represented by a space for normal polarity, and the opposite for inverted polarity. in irda format, a zero is represented by short high pulse in the middle of a bit time remaining idle low for a one for normal polarity, and a zero is represented by short low pulse in the middle of a bit time remaining idle high for a one for inverted polarity. 0 normal polarity 1 inverted polarity table 20-11. scisr1 field descriptions (continued) field description
serial communication interface (s12sciv5) mc9s12g family reference manual, rev.1.23 680 freescale semiconductor 20.3.2.9 sci data registers (scidrh, scidrl) read: anytime; reading accesses sci receive data register write: anytime; writing accesses sci transmit data register; writing to r8 has no effect 3 rxpol receive polarity ?this bit control the polarity of the received data. in nrz format, a one is represented by a mark and a zero is represented by a space for normal polarity, and the opposite for inverted polarity. in irda format, a zero is represented by short high pulse in the middle of a bit time remaining idle low for a one for normal polarity, and a zero is represented by short low pulse in the middle of a bit time remaining idle high for a one for inverted polarity. 0 normal polarity 1 inverted polarity 2 brk13 break transmit character length this bit determines whether the transmit break character is 10 or 11 bit respectively 13 or 14 bits long. the detection of a framing error is not affected by this bit. 0 break character is 10 or 11 bit long 1 break character is 13 or 14 bit long 1 txdir transmitter pin data direction in single-wire mode ?this bit determines whether the txd pin is going to be used as an input or output, in the single-wire mode of operation. this bit is only relevant in the single-wire mode of operation. 0 txd pin to be used as an input in single-wire mode 1 txd pin to be used as an output in single-wire mode 0 raf receiver active flag raf is set when the receiver detects a logic 0 during the rt1 time period of the start bit search. raf is cleared when the receiver detects an idle character. 0 no reception in progress 1 reception in progress module base + 0x0006 76543210 rr8 t8 000000 w reset 0 0 0 00000 = unimplemented or reserved figure 20-12. sci data registers (scidrh) module base + 0x0007 76543210 rr7r6r5r4r3r2r1r0 w t7 t6 t5 t4 t3 t2 t1 t0 reset 0 0 0 00000 figure 20-13. sci data registers (scidrl) table 20-12. scisr2 field descriptions (continued) field description
serial communication interface (s12sciv5) mc9s12g family reference manual, rev.1.23 freescale semiconductor 681 note if the value of t8 is the same as in the previous transmission, t8 does not have to be rewritten.the same value is transmitted until t8 is rewritten in 8-bit data format, only sci data register low (scidrl) needs to be accessed. when transmitting in 9-bit data format and using 8-bit write instructions, write ?st to sci data register high (scidrh), then scidrl. 20.4 functional description this section provides a complete functional description of the sci block, detailing the operation of the design from the end user perspective in a number of subsections. figure 20-14 shows the structure of the sci module. the sci allows full duplex, asynchronous, serial communication between the cpu and remote devices, including other cpus. the sci transmitter and receiver operate independently, although they use the same baud rate generator. the cpu monitors the status of the sci, writes the data to be transmitted, and processes received data. table 20-13. scidrh and scidrl field descriptions field description scidrh 7 r8 received bit 8 ?r8 is the ninth data bit received when the sci is con?ured for 9-bit data format (m = 1). scidrh 6 t8 transmit bit 8 ?t8 is the ninth data bit transmitted when the sci is con?ured for 9-bit data format (m = 1). scidrl 7:0 r[7:0] t[7:0] r7:r0 ?received bits seven through zero for 9-bit or 8-bit data formats t7:t0 ?transmit bits seven through zero for 9-bit or 8-bit formats
serial communication interface (s12sciv5) mc9s12g family reference manual, rev.1.23 682 freescale semiconductor figure 20-14. detailed sci block diagram 20.4.1 infrared interface submodule this module provides the capability of transmitting narrow pulses to an ir led and receiving narrow pulses and transforming them to serial bits, which are sent to the sci. the irda physical layer speci?ation de?es a half-duplex infrared communication link for exchange data. the full standard includes data rates up to 16 mbits/s. this design covers only data rates between 2.4 kbits/s and 115.2 kbits/s. the infrared submodule consists of two major blocks: the transmit encoder and the receive decoder. the sci transmits serial bits of data which are encoded by the infrared submodule to transmit a narrow pulse sci data receive shift register sci data register transmit shift register register baud rate generator sbr12:sbr0 bus transmit control 16 receive and wakeup data format control control t8 pf fe nf rdrf idle tie or tcie tdre tc r8 raf loops rwu re pe ilt pt wake m clock ilie rie rxd rsrc sbk loops te rsrc iren r16xclk ir_rxd txd ir_txd r16xclk r32xclk tnp[1:0] iren transmit encoder receive decoder scrxd sctxd infrared infrared tc tdre rdrf/or idle active edge detect break detect rxd bkdfe berrm[1:0] bkdie bkdif rxedgie rxedgif berrie berrif sci interrupt request lin transmit collision detect
serial communication interface (s12sciv5) mc9s12g family reference manual, rev.1.23 freescale semiconductor 683 for every zero bit. no pulse is transmitted for every one bit. when receiving data, the ir pulses should be detected using an ir photo diode and transformed to cmos levels by the ir receive decoder (external from the mcu). the narrow pulses are then stretched by the infrared submodule to get back to a serial bit stream to be received by the sci.the polarity of transmitted pulses and expected receive pulses can be inverted so that a direct connection can be made to external irda transceiver modules that uses active low pulses. the infrared submodule receives its clock sources from the sci. one of these two clocks are selected in the infrared submodule in order to generate either 3/16, 1/16, 1/32 or 1/4 narrow pulses during transmission. the infrared block receives two clock sources from the sci, r16xclk and r32xclk, which are con?ured to generate the narrow pulse width during transmission. the r16xclk and r32xclk are internal clocks with frequencies 16 and 32 times the baud rate respectively. both r16xclk and r32xclk clocks are used for transmitting data. the receive decoder uses only the r16xclk clock. 20.4.1.1 infrared transmit encoder the infrared transmit encoder converts serial bits of data from transmit shift register to the txd pin. a narrow pulse is transmitted for a zero bit and no pulse for a one bit. the narrow pulse is sent in the middle of the bit with a duration of 1/32, 1/16, 3/16 or 1/4 of a bit time. a narrow high pulse is transmitted for a zero bit when txpol is cleared, while a narrow low pulse is transmitted for a zero bit when txpol is set. 20.4.1.2 infrared receive decoder the infrared receive block converts data from the rxd pin to the receive shift register. a narrow pulse is expected for each zero received and no pulse is expected for each one received. a narrow high pulse is expected for a zero bit when rxpol is cleared, while a narrow low pulse is expected for a zero bit when rxpol is set. this receive decoder meets the edge jitter requirement as de?ed by the irda serial infrared physical layer speci?ation. 20.4.2 lin support this module provides some basic support for the lin protocol. at ?st this is a break detect circuitry making it easier for the lin software to distinguish a break character from an incoming data stream. as a further addition is supports a collision detection at the bit level as well as cancelling pending transmissions. 20.4.3 data format the sci uses the standard nrz mark/space data format. when infrared is enabled, the sci uses rzi data format where zeroes are represented by light pulses and ones remain low. see figure 20-15 below.
serial communication interface (s12sciv5) mc9s12g family reference manual, rev.1.23 684 freescale semiconductor figure 20-15. sci data formats each data character is contained in a frame that includes a start bit, eight or nine data bits, and a stop bit. clearing the m bit in sci control register 1 con?ures the sci for 8-bit data characters. a frame with eight data bits has a total of 10 bits. setting the m bit con?ures the sci for nine-bit data characters. a frame with nine data bits has a total of 11 bits. when the sci is con?ured for 9-bit data characters, the ninth data bit is the t8 bit in sci data register high (scidrh). it remains unchanged after transmission and can be used repeatedly without rewriting it. a frame with nine data bits has a total of 11 bits. table 20-14. example of 8-bit data formats start bit data bits address bits parity bits stop bit 18001 17011 17 1 1 1 the address bit identi?s the frame as an address character. see section 20.4.6.6, ?eceiver wakeup . 01 table 20-15. example of 9-bit data formats start bit data bits address bits parity bits stop bit 19001 18011 18 1 1 1 the address bit identi?s the frame as an address character. see section 20.4.6.6, ?eceiver wakeup . 01 bit 5 start bit bit 0 bit 1 next stop bit start bit 8-bit data format (bit m in scicr1 clear) start bit bit 0 next stop bit start bit 9-bit data format (bit m in scicr1 set) bit 1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7 bit 8 bit 2 bit 3 bit 4 bit 6 bit 7 possible parity bit possible parity bit standard sci data infrared sci data standard sci data infrared sci data
serial communication interface (s12sciv5) mc9s12g family reference manual, rev.1.23 freescale semiconductor 685 20.4.4 baud rate generation a 13-bit modulus counter in the baud rate generator derives the baud rate for both the receiver and the transmitter. the value from 0 to 8191 written to the sbr12:sbr0 bits determines the bus clock divisor. the sbr bits are in the sci baud rate registers (scibdh and scibdl). the baud rate clock is synchronized with the bus clock and drives the receiver. the baud rate clock divided by 16 drives the transmitter. the receiver has an acquisition rate of 16 samples per bit time. baud rate generation is subject to one source of error: integer division of the bus clock may not give the exact target frequency. table 20-16 lists some examples of achieving target baud rates with a bus clock frequency of 25 mhz. when iren = 0 then, sci baud rate = sci bus clock / (16 * scibr[12:0]) table 20-16. baud rates (example: bus clock = 25 mhz) bits sbr[12:0] receiver clock (hz) transmitter clock (hz) target baud rate error (%) 41 609,756.1 38,109.8 38,400 .76 81 308,642.0 19,290.1 19,200 .47 163 153,374.2 9585.9 9,600 .16 326 76,687.1 4792.9 4,800 .15 651 38,402.5 2400.2 2,400 .01 1302 19,201.2 1200.1 1,200 .01 2604 9600.6 600.0 600 .00 5208 4800.0 300.0 300 .00
serial communication interface (s12sciv5) mc9s12g family reference manual, rev.1.23 686 freescale semiconductor 20.4.5 transmitter figure 20-16. transmitter block diagram 20.4.5.1 transmitter character length the sci transmitter can accommodate either 8-bit or 9-bit data characters. the state of the m bit in sci control register 1 (scicr1) determines the length of data characters. when transmitting 9-bit data, bit t8 in sci data register high (scidrh) is the ninth bit (bit 8). 20.4.5.2 character transmission to transmit data, the mcu writes the data bits to the sci data registers (scidrh/scidrl), which in turn are transferred to the transmitter shift register. the transmit shift register then shifts a frame out through the txd pin, after it has prefaced them with a start bit and appended them with a stop bit. the sci data registers (scidrh and scidrl) are the write-only buffers between the internal data bus and the transmit shift register. pe pt h876543210l 11-bit transmit register stop start t8 tie tdre tcie sbk tc parity generation msb sci data registers load from scidr shift enable preamble (all 1s) break (all 0s) transmitter control m internal bus sbr12:sbr0 baud divider 16 bus clock te sctxd txpol loops loop rsrc control to receiver transmit collision detect tdre irq tc irq sctxd scrxd (from receiver) tcie berrif ber irq berrm[1:0]
serial communication interface (s12sciv5) mc9s12g family reference manual, rev.1.23 freescale semiconductor 687 the sci also sets a ?g, the transmit data register empty ?g (tdre), every time it transfers data from the buffer (scidrh/l) to the transmitter shift register.the transmit driver routine may respond to this ?g by writing another byte to the transmitter buffer (scidrh/scidrl), while the shift register is still shifting out the ?st byte. to initiate an sci transmission: 1. con?ure the sci: a) select a baud rate. write this value to the sci baud registers (scibdh/l) to begin the baud rate generator. remember that the baud rate generator is disabled when the baud rate is zero. writing to the scibdh has no effect without also writing to scibdl. b) write to scicr1 to con?ure word length, parity, and other con?uration bits (loops,rsrc,m,wake,ilt,pe,pt). c) enable the transmitter, interrupts, receive, and wake up as required, by writing to the scicr2 register bits (tie,tcie,rie,ilie,te,re,rwu,sbk). a preamble or idle character will now be shifted out of the transmitter shift register. 2. transmit procedure for each byte: a) poll the tdre ?g by reading the scisr1 or responding to the tdre interrupt. keep in mind that the tdre bit resets to one. b) if the tdre ?g is set, write the data to be transmitted to scidrh/l, where the ninth bit is written to the t8 bit in scidrh if the sci is in 9-bit data format. a new transmission will not result until the tdre ?g has been cleared. 3. repeat step 2 for each subsequent transmission. note the tdre ?g is set when the shift register is loaded with the next data to be transmitted from scidrh/l, which happens, generally speaking, a little over half-way through the stop bit of the previous frame. speci?ally, this transfer occurs 9/16ths of a bit time after the start of the stop bit of the previous frame. writing the te bit from 0 to a 1 automatically loads the transmit shift register with a preamble of 10 logic 1s (if m = 0) or 11 logic 1s (if m = 1). after the preamble shifts out, control logic transfers the data from the sci data register into the transmit shift register. a logic 0 start bit automatically goes into the least signi?ant bit position of the transmit shift register. a logic 1 stop bit goes into the most signi?ant bit position. hardware supports odd or even parity. when parity is enabled, the most signi?ant bit (msb) of the data character is the parity bit. the transmit data register empty ?g, tdre, in sci status register 1 (scisr1) becomes set when the sci data register transfers a byte to the transmit shift register. the tdre ?g indicates that the sci data register can accept new data from the internal data bus. if the transmit interrupt enable bit, tie, in sci control register 2 (scicr2) is also set, the tdre ?g generates a transmitter interrupt request.
serial communication interface (s12sciv5) mc9s12g family reference manual, rev.1.23 688 freescale semiconductor when the transmit shift register is not transmitting a frame, the txd pin goes to the idle condition, logic 1. if at any time software clears the te bit in sci control register 2 (scicr2), the transmitter enable signal goes low and the transmit signal goes idle. if software clears te while a transmission is in progress (tc = 0), the frame in the transmit shift register continues to shift out. to avoid accidentally cutting off the last frame in a message, always wait for tdre to go high after the last frame before clearing te. to separate messages with preambles with minimum idle line time, use this sequence between messages: 1. write the last byte of the ?st message to scidrh/l. 2. wait for the tdre ?g to go high, indicating the transfer of the last frame to the transmit shift register. 3. queue a preamble by clearing and then setting the te bit. 4. write the ?st byte of the second message to scidrh/l. 20.4.5.3 break characters writing a logic 1 to the send break bit, sbk, in sci control register 2 (scicr2) loads the transmit shift register with a break character. a break character contains all logic 0s and has no start, stop, or parity bit. break character length depends on the m bit in sci control register 1 (scicr1). as long as sbk is at logic 1, transmitter logic continuously loads break characters into the transmit shift register. after software clears the sbk bit, the shift register ?ishes transmitting the last break character and then transmits at least one logic 1. the automatic logic 1 at the end of a break character guarantees the recognition of the start bit of the next frame. the sci recognizes a break character when there are 10 or 11(m = 0 or m = 1) consecutive zero received. depending if the break detect feature is enabled or not receiving a break character has these effects on sci registers. if the break detect feature is disabled (bkdfe = 0): sets the framing error ?g, fe sets the receive data register full ?g, rdrf clears the sci data registers (scidrh/l) may set the overrun ?g, or, noise ?g, nf, parity error ?g, pe, or the receiver active ?g, raf (see 3.4.4 and 3.4.5 sci status register 1 and 2) if the break detect feature is enabled (bkdfe = 1) there are two scenarios 1 the break is detected right from a start bit or is detected during a byte reception. sets the break detect interrupt ?g, bkdif does not change the data register full ?g, rdrf or overrun ?g or does not change the framing error ?g fe, parity error ?g pe. does not clear the sci data registers (scidrh/l) may set noise ?g nf, or receiver active ?g raf. 1. a break character in this context are either 10 or 11 consecutive zero received bits
serial communication interface (s12sciv5) mc9s12g family reference manual, rev.1.23 freescale semiconductor 689 figure 20-17 shows two cases of break detect. in trace rxd_1 the break symbol starts with the start bit, while in rxd_2 the break starts in the middle of a transmission. if brkdfe = 1, in rxd_1 case there will be no byte transferred to the receive buffer and the rdrf ?g will not be modi?d. also no framing error or parity error will be ?gged from this transfer. in rxd_2 case, however the break signal starts later during the transmission. at the expected stop bit position the byte received so far will be transferred to the receive buffer, the receive data register full ?g will be set, a framing error and if enabled and appropriate a parity error will be set. once the break is detected the brkdif ?g will be set. figure 20-17. break detection if brkdfe = 1 (m = 0) 20.4.5.4 idle characters an idle character (or preamble) contains all logic 1s and has no start, stop, or parity bit. idle character length depends on the m bit in sci control register 1 (scicr1). the preamble is a synchronizing idle character that begins the ?st transmission initiated after writing the te bit from 0 to 1. if the te bit is cleared during a transmission, the txd pin becomes idle after completion of the transmission in progress. clearing and then setting the te bit during a transmission queues an idle character to be sent after the frame currently being transmitted. note when queueing an idle character, return the te bit to logic 1 before the stop bit of the current frame shifts out through the txd pin. setting te after the stop bit appears on txd causes data previously written to the sci data register to be lost. toggle the te bit for a queued idle character while the tdre ?g is set and immediately before writing the next byte to the sci data register. if the te bit is clear and the transmission is complete, the sci is not the master of the txd pin start bit position stop bit position brkdif = 1 fe = 1 brkdif = 1 rxd_1 rxd_2 1 23 4567 8 910 1 23 4567 8 910 zero bit counter zero bit counter . . . . . .
serial communication interface (s12sciv5) mc9s12g family reference manual, rev.1.23 690 freescale semiconductor 20.4.5.5 lin transmit collision detection this module allows to check for collisions on the lin bus. figure 20-18. collision detect principle if the bit error circuit is enabled (berrm[1:0] = 0:1 or = 1:0]), the error detect circuit will compare the transmitted and the received data stream at a point in time and ?g any mismatch. the timing checks run when transmitter is active (not idle). as soon as a mismatch between the transmitted data and the received data is detected the following happens: the next bit transmitted will have a high level (txpol = 0) or low level (txpol = 1) the transmission is aborted and the byte in transmit buffer is discarded. the transmit data register empty and the transmission complete ?g will be set the bit error interrupt ?g, berrif, will be set. no further transmissions will take place until the berrif is cleared. figure 20-19. timing diagram bit error detection if the bit error detect feature is disabled, the bit error interrupt ?g is cleared. note the rxpol and txpol bit should be set the same when transmission collision detect feature is enabled, otherwise the bit error interrupt ?g may be set incorrectly. txd pin rxd pin lin physical interface synchronizer stage bus clock receive shift register transmit shift register lin bus compare sample bit error point output transmit shift register 01234567891011121314150 input receive shift register berrm[1:0] = 0:1 berrm[1:0] = 1:1 compare sample points sampling begin sampling begin sampling end sampling end
serial communication interface (s12sciv5) mc9s12g family reference manual, rev.1.23 freescale semiconductor 691 20.4.6 receiver figure 20-20. sci receiver block diagram 20.4.6.1 receiver character length the sci receiver can accommodate either 8-bit or 9-bit data characters. the state of the m bit in sci control register 1 (scicr1) determines the length of data characters. when receiving 9-bit data, bit r8 in sci data register high (scidrh) is the ninth bit (bit 8). 20.4.6.2 character reception during an sci reception, the receive shift register shifts a frame in from the rxd pin. the sci data register is the read-only buffer between the internal data bus and the receive shift register. after a complete frame shifts into the receive shift register, the data portion of the frame transfers to the sci data register. the receive data register full ?g, rdrf, in sci status register 1 (scisr1) becomes set, all 1s m wake ilt pe pt re h876543210l 11-bit receive shift register stop start data wakeup parity checking msb sci data register r8 ilie rwu rdrf or nf fe pe internal bus bus sbr12:sbr0 baud divider clock idle raf recovery logic rxpol loops loop rsrc control scrxd from txd pin or transmitter idle irq rdrf/or irq break detect logic active edge detect logic brkdfe brkdie brkdif rxedgie rxedgif break irq rx active edge irq rie
serial communication interface (s12sciv5) mc9s12g family reference manual, rev.1.23 692 freescale semiconductor indicating that the received byte can be read. if the receive interrupt enable bit, rie, in sci control register 2 (scicr2) is also set, the rdrf ?g generates an rdrf interrupt request. 20.4.6.3 data sampling the rt clock rate. the rt clock is an internal signal with a frequency 16 times the baud rate. to adjust for baud rate mismatch, the rt clock (see figure 20-21 ) is re-synchronized: after every start bit after the receiver detects a data bit change from logic 1 to logic 0 (after the majority of data bit samples at rt8, rt9, and rt10 returns a valid logic 1 and the majority of the next rt8, rt9, and rt10 samples returns a valid logic 0) to locate the start bit, data recovery logic does an asynchronous search for a logic 0 preceded by three logic 1s.when the falling edge of a possible start bit occurs, the rt clock begins to count to 16. figure 20-21. receiver data sampling to verify the start bit and to detect noise, data recovery logic takes samples at rt3, rt5, and rt7. figure 20-17 summarizes the results of the start bit veri?ation samples. if start bit veri?ation is not successful, the rt clock is reset and a new search for a start bit begins. table 20-17. start bit veri?ation rt3, rt5, and rt7 samples start bit veri?ation noise flag 000 yes 0 001 yes 1 010 yes 1 011 no 0 100 yes 1 101 no 0 110 no 0 111 no 0 reset rt clock rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt2 rt3 rt4 rt5 rt8 rt7 rt6 rt11 rt10 rt9 rt15 rt14 rt13 rt12 rt16 rt1 rt2 rt3 rt4 samples rt clock rt clock count start bit rxd start bit quali?ation start bit data sampling 11 1 1 1 1 110000 0 00 lsb veri?ation
serial communication interface (s12sciv5) mc9s12g family reference manual, rev.1.23 freescale semiconductor 693 to determine the value of a data bit and to detect noise, recovery logic takes samples at rt8, rt9, and rt10. table 20-18 summarizes the results of the data bit samples. note the rt8, rt9, and rt10 samples do not affect start bit veri?ation. if any or all of the rt8, rt9, and rt10 start bit samples are logic 1s following a successful start bit veri?ation, the noise ?g (nf) is set and the receiver assumes that the bit is a start bit (logic 0). to verify a stop bit and to detect noise, recovery logic takes samples at rt8, rt9, and rt10. table 20-19 summarizes the results of the stop bit samples. in figure 20-22 the veri?ation samples rt3 and rt5 determine that the ?st low detected was noise and not the beginning of a start bit. the rt clock is reset and the start bit search begins again. the noise ?g is not set because the noise occurred before the start bit was found. table 20-18. data bit recovery rt8, rt9, and rt10 samples data bit determination noise flag 000 0 0 001 0 1 010 0 1 011 1 1 100 0 1 101 1 1 110 1 1 111 1 0 table 20-19. stop bit recovery rt8, rt9, and rt10 samples framing error flag noise flag 000 1 0 001 1 1 010 1 1 011 0 1 100 1 1 101 0 1 110 0 1 111 0 0
serial communication interface (s12sciv5) mc9s12g family reference manual, rev.1.23 694 freescale semiconductor figure 20-22. start bit search example 1 in figure 20-23 , veri?ation sample at rt3 is high. the rt3 sample sets the noise ?g. although the perceived bit time is misaligned, the data samples rt8, rt9, and rt10 are within the bit time and data recovery is successful. figure 20-23. start bit search example 2 in figure 20-24 , a large burst of noise is perceived as the beginning of a start bit, although the test sample at rt5 is high. the rt5 sample sets the noise ?g. although this is a worst-case misalignment of perceived bit time, the data samples rt8, rt9, and rt10 are within the bit time and data recovery is successful. reset rt clock rt1 rt1 rt1 rt1 rt2 rt3 rt4 rt5 rt1 rt1 rt2 rt3 rt4 rt7 rt6 rt5 rt10 rt9 rt8 rt14 rt13 rt12 rt11 rt15 rt16 rt1 rt2 rt3 samples rt clock rt clock count start bit rxd 11 0 1 111000 00 lsb 0 0 reset rt clock rt1 rt1 rt1 rt1 rt1 rt1 rt2 rt3 rt4 rt5 rt6 rt7 rt8 rt11 rt10 rt9 rt14 rt13 rt12 rt2 rt1 rt16 rt15 rt3 rt4 rt5 rt6 rt7 samples rt clock rt clock count actual start bit rxd 11 1 1 11000 0 lsb 0 0 perceived start bit
serial communication interface (s12sciv5) mc9s12g family reference manual, rev.1.23 freescale semiconductor 695 figure 20-24. start bit search example 3 figure 20-25 shows the effect of noise early in the start bit time. although this noise does not affect proper synchronization with the start bit time, it does set the noise ?g. figure 20-25. start bit search example 4 figure 20-26 shows a burst of noise near the beginning of the start bit that resets the rt clock. the sample after the reset is low but is not preceded by three high samples that would qualify as a falling edge. depending on the timing of the start bit search and on the data, the frame may be missed entirely or it may set the framing error ?g. reset rt clock rt1 rt1 rt1 rt1 rt2 rt3 rt4 rt5 rt6 rt7 rt8 rt9 rt10 rt13 rt12 rt11 rt16 rt15 rt14 rt4 rt3 rt2 rt1 rt5 rt6 rt7 rt8 rt9 samples rt clock rt clock count actual start bit rxd 10 1 11000 0 lsb 0 perceived start bit reset rt clock rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt2 rt3 rt4 rt7 rt6 rt5 rt10 rt9 rt8 rt14 rt13 rt12 rt11 rt15 rt16 rt1 rt2 rt3 samples rt clock rt clock count perceived and actual start bit rxd 11 1 1100 1 lsb 1 1 1 1
serial communication interface (s12sciv5) mc9s12g family reference manual, rev.1.23 696 freescale semiconductor figure 20-26. start bit search example 5 in figure 20-27 , a noise burst makes the majority of data samples rt8, rt9, and rt10 high. this sets the noise ?g but does not reset the rt clock. in start bits only, the rt8, rt9, and rt10 data samples are ignored. figure 20-27. start bit search example 6 20.4.6.4 framing errors if the data recovery logic does not detect a logic 1 where the stop bit should be in an incoming frame, it sets the framing error ?g, fe, in sci status register 1 (scisr1). a break character also sets the fe ?g because a break character has no stop bit. the fe ?g is set at the same time that the rdrf ?g is set. 20.4.6.5 baud rate tolerance a transmitting device may be operating at a baud rate below or above the receiver baud rate. accumulated bit time misalignment can cause one of the three stop bit data samples (rt8, rt9, and rt10) to fall outside the actual stop bit. a noise error will occur if the rt8, rt9, and rt10 samples are not all the same logical values. a framing error will occur if the receiver clock is misaligned in such a way that the majority of the rt8, rt9, and rt10 stop bit samples are a logic zero. reset rt clock rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt2 rt3 rt4 rt7 rt6 rt5 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 samples rt clock rt clock count start bit rxd 11 1 1101 0 lsb 1 1 1 1 1 00 0 00 0 0 0 no start bit found reset rt clock rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt2 rt3 rt4 rt7 rt6 rt5 rt10 rt9 rt8 rt14 rt13 rt12 rt11 rt15 rt16 rt1 rt2 rt3 samples rt clock rt clock count start bit rxd 11 1 1100 0 lsb 1 1 1 1 0 11 0
serial communication interface (s12sciv5) mc9s12g family reference manual, rev.1.23 freescale semiconductor 697 as the receiver samples an incoming frame, it re-synchronizes the rt clock on any valid falling edge within the frame. re synchronization within frames will correct a misalignment between transmitter bit times and receiver bit times. 20.4.6.5.1 slow data tolerance figure 20-28 shows how much a slow received frame can be misaligned without causing a noise error or a framing error. the slow stop bit begins at rt8 instead of rt1 but arrives in time for the stop bit data samples at rt8, rt9, and rt10. figure 20-28. slow data lets take rtr as receiver rt clock and rtt as transmitter rt clock. for an 8-bit data character, it takes the receiver 9 bit times x 16 rtr cycles +7 rtr cycles = 151 rtr cycles to start data sampling of the stop bit. with the misaligned character shown in figure 20-28 , the receiver counts 151 rtr cycles at the point when the count of the transmitting device is 9 bit times x 16 rtt cycles = 144 rtt cycles. the maximum percent difference between the receiver count and the transmitter count of a slow 8-bit data character with no errors is: ((151 ?144) / 151) x 100 = 4.63% for a 9-bit data character, it takes the receiver 10 bit times x 16 rtr cycles + 7 rtr cycles = 167 rtr cycles to start data sampling of the stop bit. with the misaligned character shown in figure 20-28 , the receiver counts 167 rtr cycles at the point when the count of the transmitting device is 10 bit times x 16 rtt cycles = 160 rtt cycles. the maximum percent difference between the receiver count and the transmitter count of a slow 9-bit character with no errors is: ((167 ?160) / 167) x 100 = 4.19% 20.4.6.5.2 fast data tolerance figure 20-29 shows how much a fast received frame can be misaligned. the fast stop bit ends at rt10 instead of rt16 but is still sampled at rt8, rt9, and rt10. msb stop rt1 rt2 rt3 rt4 rt5 rt6 rt7 rt8 rt9 rt10 rt11 rt12 rt13 rt14 rt15 rt16 data samples receiver rt clock
serial communication interface (s12sciv5) mc9s12g family reference manual, rev.1.23 698 freescale semiconductor figure 20-29. fast data for an 8-bit data character, it takes the receiver 9 bit times x 16 rtr cycles + 10 rtr cycles = 154 rtr cycles to ?ish data sampling of the stop bit. with the misaligned character shown in figure 20-29 , the receiver counts 154 rtr cycles at the point when the count of the transmitting device is 10 bit times x 16 rtt cycles = 160 rtt cycles. the maximum percent difference between the receiver count and the transmitter count of a fast 8-bit character with no errors is: ((160 ?154) / 160) x 100 = 3.75% for a 9-bit data character, it takes the receiver 10 bit times x 16 rtr cycles + 10 rtr cycles = 170 rtr cycles to ?ish data sampling of the stop bit. with the misaligned character shown in figure 20-29 , the receiver counts 170 rtr cycles at the point when the count of the transmitting device is 11 bit times x 16 rtt cycles = 176 rtt cycles. the maximum percent difference between the receiver count and the transmitter count of a fast 9-bit character with no errors is: ((176 ?170) /176) x 100 = 3.40% 20.4.6.6 receiver wakeup to enable the sci to ignore transmissions intended only for other receivers in multiple-receiver systems, the receiver can be put into a standby state. setting the receiver wakeup bit, rwu, in sci control register 2 (scicr2) puts the receiver into standby state during which receiver interrupts are disabled.the sci will still load the receive data into the scidrh/l registers, but it will not set the rdrf ?g. the transmitting device can address messages to selected receivers by including addressing information in the initial frame or frames of each message. the wake bit in sci control register 1 (scicr1) determines how the sci is brought out of the standby state to process an incoming message. the wake bit enables either idle line wakeup or address mark wakeup. 20.4.6.6.1 idle input line wakeup (wake = 0) in this wakeup method, an idle condition on the rxd pin clears the rwu bit and wakes up the sci. the initial frame or frames of every message contain addressing information. all receivers evaluate the addressing information, and receivers for which the message is addressed process the frames that follow. any receiver for which a message is not addressed can set its rwu bit and return to the standby state. the idle or next frame stop rt1 rt2 rt3 rt4 rt5 rt6 rt7 rt8 rt9 rt10 rt11 rt12 rt13 rt14 rt15 rt16 data samples receiver rt clock
serial communication interface (s12sciv5) mc9s12g family reference manual, rev.1.23 freescale semiconductor 699 rwu bit remains set and the receiver remains on standby until another idle character appears on the rxd pin. idle line wakeup requires that messages be separated by at least one idle character and that no message contains idle characters. the idle character that wakes a receiver does not set the receiver idle bit, idle, or the receive data register full ?g, rdrf. the idle line type bit, ilt, determines whether the receiver begins counting logic 1s as idle character bits after the start bit or after the stop bit. ilt is in sci control register 1 (scicr1). 20.4.6.6.2 address mark wakeup (wake = 1) in this wakeup method, a logic 1 in the most signi?ant bit (msb) position of a frame clears the rwu bit and wakes up the sci. the logic 1 in the msb position marks a frame as an address frame that contains addressing information. all receivers evaluate the addressing information, and the receivers for which the message is addressed process the frames that follow.any receiver for which a message is not addressed can set its rwu bit and return to the standby state. the rwu bit remains set and the receiver remains on standby until another address frame appears on the rxd pin. the logic 1 msb of an address frame clears the receivers rwu bit before the stop bit is received and sets the rdrf ?g. address mark wakeup allows messages to contain idle characters but requires that the msb be reserved for use in address frames. note with the wake bit clear, setting the rwu bit after the rxd pin has been idle can cause the receiver to wake up immediately. 20.4.7 single-wire operation normally, the sci uses two pins for transmitting and receiving. in single-wire operation, the rxd pin is disconnected from the sci. the sci uses the txd pin for both receiving and transmitting. figure 20-30. single-wire operation (loops = 1, rsrc = 1) enable single-wire operation by setting the loops bit and the receiver source bit, rsrc, in sci control register 1 (scicr1). setting the loops bit disables the path from the rxd pin to the receiver. setting the rsrc bit connects the txd pin to the receiver. both the transmitter and receiver must be enabled (te = 1 and re = 1).the txdir bit (scisr2[1]) determines whether the txd pin is going to be used as an input (txdir = 0) or an output (txdir = 1) in this mode of operation. rxd transmitter receiver txd
serial communication interface (s12sciv5) mc9s12g family reference manual, rev.1.23 700 freescale semiconductor note in single-wire operation data from the txd pin is inverted if rxpol is set. 20.4.8 loop operation in loop operation the transmitter output goes to the receiver input. the rxd pin is disconnected from the sci. figure 20-31. loop operation (loops = 1, rsrc = 0) enable loop operation by setting the loops bit and clearing the rsrc bit in sci control register 1 (scicr1). setting the loops bit disables the path from the rxd pin to the receiver. clearing the rsrc bit connects the transmitter output to the receiver input. both the transmitter and receiver must be enabled (te = 1 and re = 1). note in loop operation data from the transmitter is not recognized by the receiver if rxpol and txpol are not the same. 20.5 initialization/application information 20.5.1 reset initialization see section 20.3.2, ?egister descriptions . 20.5.2 modes of operation 20.5.2.1 run mode normal mode of operation. to initialize a sci transmission, see section 20.4.5.2, ?haracter transmission . 20.5.2.2 wait mode sci operation in wait mode depends on the state of the sciswai bit in the sci control register 1 (scicr1). if sciswai is clear, the sci operates normally when the cpu is in wait mode. if sciswai is set, sci clock generation ceases and the sci module enters a power-conservation state when the cpu is in wait mode. setting sciswai does not affect the state of the receiver enable bit, re, or the transmitter enable bit, te. rxd transmitter receiver txd
serial communication interface (s12sciv5) mc9s12g family reference manual, rev.1.23 freescale semiconductor 701 if sciswai is set, any transmission or reception in progress stops at wait mode entry. the transmission or reception resumes when either an internal or external interrupt brings the cpu out of wait mode. exiting wait mode by reset aborts any transmission or reception in progress and resets the sci. 20.5.2.3 stop mode the sci is inactive during stop mode for reduced power consumption. the stop instruction does not affect the sci register states, but the sci bus clock will be disabled. the sci operation resumes from where it left off after an external interrupt brings the cpu out of stop mode. exiting stop mode by reset aborts any transmission or reception in progress and resets the sci. the receive input active edge detect circuit is still active in stop mode. an active edge on the receive input can be used to bring the cpu out of stop mode. 20.5.3 interrupt operation this section describes the interrupt originated by the sci block.the mcu must service the interrupt requests. table 20-20 lists the eight interrupt sources of the sci. 20.5.3.1 description of interrupt operation the sci only originates interrupt requests. the following is a description of how the sci makes a request and how the mcu should acknowledge that request. the interrupt vector offset and interrupt number are chip dependent. the sci only has a single interrupt line (sci interrupt signal, active high operation) and all the following interrupts, when generated, are ored together and issued through that port. 20.5.3.1.1 tdre description the tdre interrupt is set high by the sci when the transmit shift register receives a byte from the sci data register. a tdre interrupt indicates that the transmit data register (scidrh/l) is empty and that a table 20-20. sci interrupt sources interrupt source local enable description tdre scisr1[7] tie active high level. indicates that a byte was transferred from scidrh/l to the transmit shift register. tc scisr1[6] tcie active high level. indicates that a transmit is complete. rdrf scisr1[5] rie active high level. the rdrf interrupt indicates that received data is available in the sci data register. or scisr1[3] active high level. this interrupt indicates that an overrun condition has occurred. idle scisr1[4] ilie active high level. indicates that receiver input has become idle. rxedgif sciasr1[7] rxedgie active high level. indicates that an active edge (falling for rxpol = 0, rising for rxpol = 1) was detected. berrif sciasr1[1] berrie active high level. indicates that a mismatch between transmitted and received data in a single wire application has happened. bkdif sciasr1[0] brkdie active high level. indicates that a break character has been received.
serial communication interface (s12sciv5) mc9s12g family reference manual, rev.1.23 702 freescale semiconductor new byte can be written to the scidrh/l for transmission.clear tdre by reading sci status register 1 with tdre set and then writing to sci data register low (scidrl). 20.5.3.1.2 tc description the tc interrupt is set by the sci when a transmission has been completed. transmission is completed when all bits including the stop bit (if transmitted) have been shifted out and no data is queued to be transmitted. no stop bit is transmitted when sending a break character and the tc ?g is set (providing there is no more data queued for transmission) when the break character has been shifted out. a tc interrupt indicates that there is no transmission in progress. tc is set high when the tdre ?g is set and no data, preamble, or break character is being transmitted. when tc is set, the txd pin becomes idle (logic 1). clear tc by reading sci status register 1 (scisr1) with tc set and then writing to sci data register low (scidrl).tc is cleared automatically when data, preamble, or break is queued and ready to be sent. 20.5.3.1.3 rdrf description the rdrf interrupt is set when the data in the receive shift register transfers to the sci data register. a rdrf interrupt indicates that the received data has been transferred to the sci data register and that the byte can now be read by the mcu. the rdrf interrupt is cleared by reading the sci status register one (scisr1) and then reading sci data register low (scidrl). 20.5.3.1.4 or description the or interrupt is set when software fails to read the sci data register before the receive shift register receives the next frame. the newly acquired data in the shift register will be lost in this case, but the data already in the sci data registers is not affected. the or interrupt is cleared by reading the sci status register one (scisr1) and then reading sci data register low (scidrl). 20.5.3.1.5 idle description the idle interrupt is set when 10 consecutive logic 1s (if m = 0) or 11 consecutive logic 1s (if m = 1) appear on the receiver input. once the idle is cleared, a valid frame must again set the rdrf ?g before an idle condition can set the idle ?g. clear idle by reading sci status register 1 (scisr1) with idle set and then reading sci data register low (scidrl). 20.5.3.1.6 rxedgif description the rxedgif interrupt is set when an active edge (falling if rxpol = 0, rising if rxpol = 1) on the rxd pin is detected. clear rxedgif by writing a ??to the sciasr1 sci alternative status register 1. 20.5.3.1.7 berrif description the berrif interrupt is set when a mismatch between the transmitted and the received data in a single wire application like lin was detected. clear berrif by writing a ??to the sciasr1 sci alternative status register 1. this ?g is also cleared if the bit error detect feature is disabled.
serial communication interface (s12sciv5) mc9s12g family reference manual, rev.1.23 freescale semiconductor 703 20.5.3.1.8 bkdif description the bkdif interrupt is set when a break signal was received. clear bkdif by writing a ??to the sciasr1 sci alternative status register 1. this ?g is also cleared if break detect feature is disabled. 20.5.4 recovery from wait mode the sci interrupt request can be used to bring the cpu out of wait mode. 20.5.5 recovery from stop mode an active edge on the receive input can be used to bring the cpu out of stop mode.
serial communication interface (s12sciv5) mc9s12g family reference manual, rev.1.23 704 freescale semiconductor
mc9s12g family reference manual, rev.1.23 freescale semiconductor 705 chapter 21 serial peripheral interface (s12spiv5) revision history 21.1 introduction the spi module allows a duplex, synchronous, serial communication between the mcu and peripheral devices. software can poll the spi status ?gs or the spi operation can be interrupt driven. 21.1.1 glossary of terms 21.1.2 features the spi includes these distinctive features: master mode and slave mode selectable 8 or 16-bit transfer width bidirectional mode slave select output mode fault error ?g with cpu interrupt capability revision number date author summary of changes 05.00 24 mar 2005 added 16-bit transfer width feature. spi serial peripheral interface ss slave select sck serial clock mosi master output, slave input miso master input, slave output momi master output, master input siso slave input, slave output
serial peripheral interface (s12spiv5) mc9s12g family reference manual, rev.1.23 706 freescale semiconductor double-buffered data register serial clock with programmable polarity and phase control of spi operation during wait mode 21.1.3 modes of operation the spi functions in three modes: run, wait, and stop. run mode this is the basic mode of operation. wait mode spi operation in wait mode is a con?urable low power mode, controlled by the spiswai bit located in the spicr2 register. in wait mode, if the spiswai bit is clear, the spi operates like in run mode. if the spiswai bit is set, the spi goes into a power conservative state, with the spi clock generation turned off. if the spi is con?ured as a master, any transmission in progress stops, but is resumed after cpu goes into run mode. if the spi is con?ured as a slave, reception and transmission of data continues, so that the slave stays synchronized to the master. stop mode the spi is inactive in stop mode for reduced power consumption. if the spi is con?ured as a master, any transmission in progress stops, but is resumed after cpu goes into run mode. if the spi is con?ured as a slave, reception and transmission of data continues, so that the slave stays synchronized to the master. for a detailed description of operating modes, please refer to section 21.4.7, ?ow power mode options . 21.1.4 block diagram figure 21-1 gives an overview on the spi architecture. the main parts of the spi are status, control and data registers, shifter logic, baud rate generator, master/slave control logic, and port control logic.
serial peripheral interface (s12spiv5) mc9s12g family reference manual, rev.1.23 freescale semiconductor 707 figure 21-1. spi block diagram 21.2 external signal description this section lists the name and description of all ports including inputs and outputs that do, or may, connect off chip. the spi module has a total of four external pins. 21.2.1 mosi ?master out/slave in pin this pin is used to transmit data out of the spi module when it is con?ured as a master and receive data when it is con?ured as slave. spi control register 1 spi control register 2 spi baud rate register spi status register spi data register shifter port control logic mosi sck interrupt control spi msb lsb lsbfe=1 lsbfe=0 lsbfe=0 lsbfe=1 data in lsbfe=1 lsbfe=0 data out baud rate generator prescaler bus clock counter clock select sppr 3 3 spr baud rate phase + polarity control master slave sck in sck out master baud rate slave baud rate phase + polarity control control control cpol cpha 2 bidiroe spc0 2 shift sample clock clock modf spif sptef spi request interrupt ss
serial peripheral interface (s12spiv5) mc9s12g family reference manual, rev.1.23 708 freescale semiconductor 21.2.2 miso ?master in/slave out pin this pin is used to transmit data out of the spi module when it is con?ured as a slave and receive data when it is con?ured as master. 21.2.3 ss ?slave select pin this pin is used to output the select signal from the spi module to another peripheral with which a data transfer is to take place when it is con?ured as a master and it is used as an input to receive the slave select signal when the spi is con?ured as slave. 21.2.4 sck ?serial clock pin in master mode, this is the synchronous output clock. in slave mode, this is the synchronous input clock. 21.3 memory map and register de?ition this section provides a detailed description of address space and registers used by the spi. 21.3.1 module memory map the memory map for the spi is given in figure 21-2 . the address listed for each register is the sum of a base address and an address offset. the base address is de?ed at the soc level and the address offset is de?ed at the module level. reads from the reserved bits return zeros and writes to the reserved bits have no effect. register name bit 7 6 5 4 3 2 1 bit 0 0x0000 spicr1 r spie spe sptie mstr cpol cpha ssoe lsbfe w 0x0001 spicr2 r0 xfrw 0 modfen bidiroe 0 spiswai spc0 w 0x0002 spibr r0 sppr2 sppr1 sppr0 0 spr2 spr1 spr0 w 0x0003 spisr r spif 0 sptef modf 0 0 0 0 w 0x0004 spidrh r r15 r14 r13 r12 r11 r10 r9 r8 t15 t14 t13 t12 t11 t10 t9 t8 w = unimplemented or reserved figure 21-2. spi register summary
serial peripheral interface (s12spiv5) mc9s12g family reference manual, rev.1.23 freescale semiconductor 709 21.3.2 register descriptions this section consists of register descriptions in address order. each description includes a standard register diagram with an associated ?ure number. details of register bit and ?ld function follow the register diagrams, in bit order. 21.3.2.1 spi control register 1 (spicr1) read: anytime write: anytime 0x0005 spidrl rr7r6r5r4r3r2r1r0 t7 t6 t5 t4 t3 t2 t1 t0 w 0x0006 reserved r w 0x0007 reserved r w module base +0x0000 76543210 r spie spe sptie mstr cpol cpha ssoe lsbfe w reset 0 0 0 00100 figure 21-3. spi control register 1 (spicr1) table 21-1. spicr1 field descriptions field description 7 spie spi interrupt enable bit ?this bit enables spi interrupt requests, if spif or modf status ?g is set. 0 spi interrupts disabled. 1 spi interrupts enabled. 6 spe spi system enable bit ?this bit enables the spi system and dedicates the spi port pins to spi system functions. if spe is cleared, spi is disabled and forced into idle state, status bits in spisr register are reset. 0 spi disabled (lower power consumption). 1 spi enabled, port pins are dedicated to spi functions. 5 sptie spi transmit interrupt enable ?this bit enables spi interrupt requests, if sptef ?g is set. 0 sptef interrupt disabled. 1 sptef interrupt enabled. register name bit 7 6 5 4 3 2 1 bit 0 = unimplemented or reserved figure 21-2. spi register summary
serial peripheral interface (s12spiv5) mc9s12g family reference manual, rev.1.23 710 freescale semiconductor 21.3.2.2 spi control register 2 (spicr2) read: anytime write: anytime; writes to the reserved bits have no effect 4 mstr spi master/slave mode select bit ?this bit selects whether the spi operates in master or slave mode. switching the spi from master to slave or vice versa forces the spi system into idle state. 0 spi is in slave mode. 1 spi is in master mode. 3 cpol spi clock polarity bit this bit selects an inverted or non-inverted spi clock. to transmit data between spi modules, the spi modules must have identical cpol values. in master mode, a change of this bit will abort a transmission in progress and force the spi system into idle state. 0 active-high clocks selected. in idle state sck is low. 1 active-low clocks selected. in idle state sck is high. 2 cpha spi clock phase bit this bit is used to select the spi clock format. in master mode, a change of this bit will abort a transmission in progress and force the spi system into idle state. 0 sampling of data occurs at odd edges (1,3,5,...) of the sck clock. 1 sampling of data occurs at even edges (2,4,6,...) of the sck clock. 1 ssoe slave select output enable ?the ss output feature is enabled only in master mode, if modfen is set, by asserting the ssoe as shown in table 21-2 . in master mode, a change of this bit will abort a transmission in progress and force the spi system into idle state. 0 lsbfe lsb-first enable ?this bit does not affect the position of the msb and lsb in the data register. reads and writes of the data register always have the msb in the highest bit position. in master mode, a change of this bit will abort a transmission in progress and force the spi system into idle state. 0 data is transferred most signi?ant bit ?st. 1 data is transferred least signi?ant bit ?st. table 21-2. ss input / output selection modfen ssoe master mode slave mode 00 ss not used by spi ss input 01 ss not used by spi ss input 10 ss input with modf feature ss input 11 ss is slave select output ss input module base +0x0001 76543210 r0 xfrw 0 modfen bidiroe 0 spiswai spc0 w reset 0 0 0 00000 = unimplemented or reserved figure 21-4. spi control register 2 (spicr2) table 21-1. spicr1 field descriptions field description
serial peripheral interface (s12spiv5) mc9s12g family reference manual, rev.1.23 freescale semiconductor 711 table 21-3. spicr2 field descriptions field description 6 xfrw transfer width this bit is used for selecting the data transfer width. if 8-bit transfer width is selected, spidrl becomes the dedicated data register and spidrh is unused. if 16-bit transfer width is selected, spidrh and spidrl form a 16-bit data register. please refer to section 21.3.2.4, ?pi status register (spisr) for information about transmit/receive data handling and the interrupt ?g clearing mechanism. in master mode, a change of this bit will abort a transmission in progress and force the spi system into idle state. 0 8-bit transfer width (n = 8) 1 1 16-bit transfer width (n = 16) 1 1 n is used later in this document as a placeholder for the selected transfer width. 4 modfen mode fault enable bit ?this bit allows the modf failure to be detected. if the spi is in master mode and modfen is cleared, then the ss port pin is not used by the spi. in slave mode, the ss is available only as an input regardless of the value of modfen. for an overview on the impact of the modfen bit on the ss port pin con?uration, refer to table 21-2 . in master mode, a change of this bit will abort a transmission in progress and force the spi system into idle state. 0 ss port pin is not used by the spi. 1 ss port pin with modf feature. 3 bidiroe output enable in the bidirectional mode of operation this bit controls the mosi and miso output buffer of the spi, when in bidirectional mode of operation (spc0 is set). in master mode, this bit controls the output buffer of the mosi port, in slave mode it controls the output buffer of the miso port. in master mode, with spc0 set, a change of this bit will abort a transmission in progress and force the spi into idle state. 0 output buffer disabled. 1 output buffer enabled. 1 spiswai spi stop in wait mode bit ?this bit is used for power conservation while in wait mode. 0 spi clock operates normally in wait mode. 1 stop spi clock generation when in wait mode. 0 spc0 serial pin control bit 0 ?this bit enables bidirectional pin con?urations as shown in table 21-4 . in master mode, a change of this bit will abort a transmission in progress and force the spi system into idle state. table 21-4. bidirectional pin con?urations pin mode spc0 bidiroe miso mosi master mode of operation normal 0 x master in master out bidirectional 1 0 miso not used by spi master in 1 master i/o slave mode of operation normal 0 x slave out slave in bidirectional 1 0 slave in mosi not used by spi 1 slave i/o
serial peripheral interface (s12spiv5) mc9s12g family reference manual, rev.1.23 712 freescale semiconductor 21.3.2.3 spi baud rate register (spibr) read: anytime write: anytime; writes to the reserved bits have no effect the baud rate divisor equation is as follows: baudratedivisor = (sppr + 1) ? 2 (spr + 1) eqn. 21-1 the baud rate can be calculated with the following equation: baud rate = busclock / baudratedivisor eqn. 21-2 note for maximum allowed baud rates, please refer to the spi electrical speci?ation in the electricals chapter of this data sheet. module base +0x0002 76543210 r0 sppr2 sppr1 sppr0 0 spr2 spr1 spr0 w reset 0 0 0 00000 = unimplemented or reserved figure 21-5. spi baud rate register (spibr) table 21-5. spibr field descriptions field description 6? sppr[2:0] spi baud rate preselection bits these bits specify the spi baud rates as shown in table 21-6 . in master mode, a change of these bits will abort a transmission in progress and force the spi system into idle state. 2? spr[2:0] spi baud rate selection bits these bits specify the spi baud rates as shown in table 21-6 . in master mode, a change of these bits will abort a transmission in progress and force the spi system into idle state. table 21-6. example spi baud rate selection (25 mhz bus clock) sppr2 sppr1 sppr0 spr2 spr1 spr0 baud rate divisor baud rate 0 0 0 0 0 0 2 12.5 mbit/s 0 0 0 0 0 1 4 6.25 mbit/s 0 0 0 0 1 0 8 3.125 mbit/s 0 0 0 0 1 1 16 1.5625 mbit/s 0 0 0 1 0 0 32 781.25 kbit/s 0 0 0 1 0 1 64 390.63 kbit/s 0 0 0 1 1 0 128 195.31 kbit/s 0 0 0 1 1 1 256 97.66 kbit/s 0 0 1 0 0 0 4 6.25 mbit/s 0 0 1 0 0 1 8 3.125 mbit/s
serial peripheral interface (s12spiv5) mc9s12g family reference manual, rev.1.23 freescale semiconductor 713 0 0 1 0 1 0 16 1.5625 mbit/s 0 0 1 0 1 1 32 781.25 kbit/s 0 0 1 1 0 0 64 390.63 kbit/s 0 0 1 1 0 1 128 195.31 kbit/s 0 0 1 1 1 0 256 97.66 kbit/s 0 0 1 1 1 1 512 48.83 kbit/s 0 1 0 0 0 0 6 4.16667 mbit/s 0 1 0 0 0 1 12 2.08333 mbit/s 0 1 0 0 1 0 24 1.04167 mbit/s 0 1 0 0 1 1 48 520.83 kbit/s 0 1 0 1 0 0 96 260.42 kbit/s 0 1 0 1 0 1 192 130.21 kbit/s 0 1 0 1 1 0 384 65.10 kbit/s 0 1 0 1 1 1 768 32.55 kbit/s 0 1 1 0 0 0 8 3.125 mbit/s 0 1 1 0 0 1 16 1.5625 mbit/s 0 1 1 0 1 0 32 781.25 kbit/s 0 1 1 0 1 1 64 390.63 kbit/s 0 1 1 1 0 0 128 195.31 kbit/s 0 1 1 1 0 1 256 97.66 kbit/s 0 1 1 1 1 0 512 48.83 kbit/s 0 1 1 1 1 1 1024 24.41 kbit/s 1 0 0 0 0 0 10 2.5 mbit/s 1 0 0 0 0 1 20 1.25 mbit/s 1 0 0 0 1 0 40 625 kbit/s 1 0 0 0 1 1 80 312.5 kbit/s 1 0 0 1 0 0 160 156.25 kbit/s 1 0 0 1 0 1 320 78.13 kbit/s 1 0 0 1 1 0 640 39.06 kbit/s 1 0 0 1 1 1 1280 19.53 kbit/s 1 0 1 0 0 0 12 2.08333 mbit/s 1 0 1 0 0 1 24 1.04167 mbit/s 1 0 1 0 1 0 48 520.83 kbit/s 1 0 1 0 1 1 96 260.42 kbit/s 1 0 1 1 0 0 192 130.21 kbit/s 1 0 1 1 0 1 384 65.10 kbit/s 1 0 1 1 1 0 768 32.55 kbit/s 1 0 1 1 1 1 1536 16.28 kbit/s 1 1 0 0 0 0 14 1.78571 mbit/s table 21-6. example spi baud rate selection (25 mhz bus clock) sppr2 sppr1 sppr0 spr2 spr1 spr0 baud rate divisor baud rate
serial peripheral interface (s12spiv5) mc9s12g family reference manual, rev.1.23 714 freescale semiconductor 21.3.2.4 spi status register (spisr) read: anytime write: has no effect 1 1 0 0 0 1 28 892.86 kbit/s 1 1 0 0 1 0 56 446.43 kbit/s 1 1 0 0 1 1 112 223.21 kbit/s 1 1 0 1 0 0 224 111.61 kbit/s 1 1 0 1 0 1 448 55.80 kbit/s 1 1 0 1 1 0 896 27.90 kbit/s 1 1 0 1 1 1 1792 13.95 kbit/s 1 1 1 0 0 0 16 1.5625 mbit/s 1 1 1 0 0 1 32 781.25 kbit/s 1 1 1 0 1 0 64 390.63 kbit/s 1 1 1 0 1 1 128 195.31 kbit/s 1 1 1 1 0 0 256 97.66 kbit/s 1 1 1 1 0 1 512 48.83 kbit/s 1 1 1 1 1 0 1024 24.41 kbit/s 1 1 1 1 1 1 2048 12.21 kbit/s module base +0x0003 76543210 r spif 0 sptef modf 0000 w reset 0 0 1 00000 = unimplemented or reserved figure 21-6. spi status register (spisr) table 21-7. spisr field descriptions field description 7 spif spif interrupt flag ?this bit is set after received data has been transferred into the spi data register. for information about clearing spif flag, please refer to table 21-8 . 0 transfer not yet complete. 1 new data copied to spidr. table 21-6. example spi baud rate selection (25 mhz bus clock) sppr2 sppr1 sppr0 spr2 spr1 spr0 baud rate divisor baud rate
serial peripheral interface (s12spiv5) mc9s12g family reference manual, rev.1.23 freescale semiconductor 715 table 21-8. spif interrupt flag clearing sequence table 21-9. sptef interrupt flag clearing sequence 5 sptef spi transmit empty interrupt flag ?if set, this bit indicates that the transmit data register is empty. for information about clearing this bit and placing data into the transmit data register, please refer to table 21-9 . 0 spi data register not empty. 1 spi data register empty. 4 modf mode fault flag this bit is set if the ss input becomes low while the spi is con?ured as a master and mode fault detection is enabled, modfen bit of spicr2 register is set. refer to modfen bit description in section 21.3.2.2, ?pi control register 2 (spicr2) . the ?g is cleared automatically by a read of the spi status register (with modf set) followed by a write to the spi control register 1. 0 mode fault has not occurred. 1 mode fault has occurred. xfrw bit spif interrupt flag clearing sequence 0 read spisr with spif == 1 then read spidrl 1 read spisr with spif == 1 then byte read spidrl 1 1 data in spidrh is lost in this case. or byte read spidrh 2 2 spidrh can be read repeatedly without any effect on spif. spif flag is cleared only by the read of spidrl after reading spisr with spif == 1. byte read spidrl or word read (spidrh:spidrl) xfrw bit sptef interrupt flag clearing sequence 0 read spisr with sptef == 1 then write to spidrl 1 1 any write to spidrh or spidrl with sptef == 0 is effectively ignored. 1 read spisr with sptef == 1 then byte write to spidrl 12 2 data in spidrh is unde?ed in this case. or byte write to spidrh 13 byte write to spidrl 1 or word write to (spidrh:spidrl) 1 table 21-7. spisr field descriptions field description
serial peripheral interface (s12spiv5) mc9s12g family reference manual, rev.1.23 716 freescale semiconductor 21.3.2.5 spi data register (spidr = spidrh:spidrl) read: anytime; read data only valid when spif is set write: anytime the spi data register is both the input and output register for spi data. a write to this register allows data to be queued and transmitted. for an spi con?ured as a master, queued data is transmitted immediately after the previous transmission has completed. the spi transmitter empty ?g sptef in the spisr register indicates when the spi data register is ready to accept new data. received data in the spidr is valid when spif is set. if spif is cleared and data has been received, the received data is transferred from the receive shift register to the spidr and spif is set. if spif is set and not serviced, and a second data value has been received, the second received data is kept as valid data in the receive shift register until the start of another transmission. the data in the spidr does not change. if spif is set and valid data is in the receive shift register, and spif is serviced before the start of a third transmission, the data in the receive shift register is transferred into the spidr and spif remains set (see figure 21-9 ). if spif is set and valid data is in the receive shift register, and spif is serviced after the start of a third transmission, the data in the receive shift register has become invalid and is not transferred into the spidr (see figure 21-10 ). 3 spidrh can be written repeatedly without any effect on sptef. sptef flag is cleared only by writing to spidrl after reading spisr with sptef == 1. module base +0x0004 76543210 r r15 r14 r13 r12 r11 r10 r9 r8 w t15 t14 t13 t12 t11 t10 t9 t8 reset 0 0 0 00000 figure 21-7. spi data register high (spidrh) module base +0x0005 76543210 r r7 r6 r5 r4 r3 r2 r1 r0 w t7 t6 t5 t4 t3 t2 t1 t0 reset 0 0 0 00000 figure 21-8. spi data register low (spidrl)
serial peripheral interface (s12spiv5) mc9s12g family reference manual, rev.1.23 freescale semiconductor 717 figure 21-9. reception with spif serviced in time figure 21-10. reception with spif serviced too late 21.4 functional description the spi module allows a duplex, synchronous, serial communication between the mcu and peripheral devices. software can poll the spi status ?gs or spi operation can be interrupt driven. the spi system is enabled by setting the spi enable (spe) bit in spi control register 1. while spe is set, the four associated spi port pins are dedicated to the spi function as: slave select ( ss) serial clock (sck) master out/slave in (mosi) master in/slave out (miso) receive shift register spif spi data register data a data b data a data a received data b received data c data c spif serviced data c received data b = unspeci?d = reception in progress receive shift register spif spi data register data a data b data a data a received data b received data c data c spif serviced data c received data b lost = unspeci?d = reception in progress
serial peripheral interface (s12spiv5) mc9s12g family reference manual, rev.1.23 718 freescale semiconductor the main element of the spi system is the spi data register. the n-bit 1 data register in the master and the n-bit 1 data register in the slave are linked by the mosi and miso pins to form a distributed 2n-bit 1 register. when a data transfer operation is performed, this 2n-bit 1 register is serially shifted n 1 bit positions by the s-clock from the master, so data is exchanged between the master and the slave. data written to the master spi data register becomes the output data for the slave, and data read from the master spi data register after a transfer operation is the input data from the slave. a read of spisr with sptef = 1 followed by a write to spidr puts data into the transmit data register. when a transfer is complete and spif is cleared, received data is moved into the receive data register. this data register acts as the spi receive data register for reads and as the spi transmit data register for writes. a common spi data register address is shared for reading data from the read data buffer and for writing data to the transmit data register. the clock phase control bit (cpha) and a clock polarity control bit (cpol) in the spi control register 1 (spicr1) select one of four possible clock formats to be used by the spi system. the cpol bit simply selects a non-inverted or inverted clock. the cpha bit is used to accommodate two fundamentally different protocols by sampling data on odd numbered sck edges or on even numbered sck edges (see section 21.4.3, ?ransmission formats ). the spi can be con?ured to operate as a master or as a slave. when the mstr bit in spi control register1 is set, master mode is selected, when the mstr bit is clear, slave mode is selected. note a change of cpol or mstr bit while there is a received byte pending in the receive shift register will destroy the received byte and must be avoided. 21.4.1 master mode the spi operates in master mode when the mstr bit is set. only a master spi module can initiate transmissions. a transmission begins by writing to the master spi data register. if the shift register is empty, data immediately transfers to the shift register. data begins shifting out on the mosi pin under the control of the serial clock. serial clock the spr2, spr1, and spr0 baud rate selection bits, in conjunction with the sppr2, sppr1, and sppr0 baud rate preselection bits in the spi baud rate register, control the baud rate generator and determine the speed of the transmission. the sck pin is the spi clock output. through the sck pin, the baud rate generator of the master controls the shift register of the slave peripheral. mosi, miso pin in master mode, the function of the serial data output pin (mosi) and the serial data input pin (miso) is determined by the spc0 and bidiroe control bits. ss pin if modfen and ssoe are set, the ss pin is con?ured as slave select output. the ss output becomes low during each transmission and is high when the spi is in idle state. 1. n depends on the selected transfer width, please refer to section 21.3.2.2, ?pi control register 2 (spicr2)
serial peripheral interface (s12spiv5) mc9s12g family reference manual, rev.1.23 freescale semiconductor 719 if modfen is set and ssoe is cleared, the ss pin is con?ured as input for detecting mode fault error. if the ss input becomes low this indicates a mode fault error where another master tries to drive the mosi and sck lines. in this case, the spi immediately switches to slave mode, by clearing the mstr bit and also disables the slave output buffer miso (or siso in bidirectional mode). so the result is that all outputs are disabled and sck, mosi, and miso are inputs. if a transmission is in progress when the mode fault occurs, the transmission is aborted and the spi is forced into idle state. this mode fault error also sets the mode fault (modf) ?g in the spi status register (spisr). if the spi interrupt enable bit (spie) is set when the modf ?g becomes set, then an spi interrupt sequence is also requested. when a write to the spi data register in the master occurs, there is a half sck-cycle delay. after the delay, sck is started within the master. the rest of the transfer operation differs slightly, depending on the clock format speci?d by the spi clock phase bit, cpha, in spi control register 1 (see section 21.4.3, ?ransmission formats? . note a change of the bits cpol, cpha, ssoe, lsbfe, xfrw, modfen, spc0, or bidiroe with spc0 set, sppr2-sppr0 and spr2-spr0 in master mode will abort a transmission in progress and force the spi into idle state. the remote slave cannot detect this, therefore the master must ensure that the remote slave is returned to idle state. 21.4.2 slave mode the spi operates in slave mode when the mstr bit in spi control register 1 is clear. serial clock in slave mode, sck is the spi clock input from the master. miso, mosi pin in slave mode, the function of the serial data output pin (miso) and serial data input pin (mosi) is determined by the spc0 bit and bidiroe bit in spi control register 2. ss pin the ss pin is the slave select input. before a data transmission occurs, the ss pin of the slave spi must be low. ss must remain low until the transmission is complete. if ss goes high, the spi is forced into idle state. the ss input also controls the serial data output pin, if ss is high (not selected), the serial data output pin is high impedance, and, if ss is low, the ?st bit in the spi data register is driven out of the serial data output pin. also, if the slave is not selected ( ss is high), then the sck input is ignored and no internal shifting of the spi shift register occurs. although the spi is capable of duplex operation, some spi peripherals are capable of only receiving spi data in a slave mode. for these simpler devices, there is no serial data out pin.
serial peripheral interface (s12spiv5) mc9s12g family reference manual, rev.1.23 720 freescale semiconductor note when peripherals with duplex capability are used, take care not to simultaneously enable two receivers whose serial outputs drive the same system slaves serial data output line. as long as no more than one slave device drives the system slaves serial data output line, it is possible for several slaves to receive the same transmission from a master, although the master would not receive return information from all of the receiving slaves. if the cpha bit in spi control register 1 is clear, odd numbered edges on the sck input cause the data at the serial data input pin to be latched. even numbered edges cause the value previously latched from the serial data input pin to shift into the lsb or msb of the spi shift register, depending on the lsbfe bit. if the cpha bit is set, even numbered edges on the sck input cause the data at the serial data input pin to be latched. odd numbered edges cause the value previously latched from the serial data input pin to shift into the lsb or msb of the spi shift register, depending on the lsbfe bit. when cpha is set, the ?st edge is used to get the ?st data bit onto the serial data output pin. when cpha is clear and the ss input is low (slave selected), the ?st bit of the spi data is driven out of the serial data output pin. after the nth 1 shift, the transfer is considered complete and the received data is transferred into the spi data register. to indicate transfer is complete, the spif ?g in the spi status register is set. note a change of the bits cpol, cpha, ssoe, lsbfe, modfen, spc0, or bidiroe with spc0 set in slave mode will corrupt a transmission in progress and must be avoided. 21.4.3 transmission formats during an spi transmission, data is transmitted (shifted out serially) and received (shifted in serially) simultaneously. the serial clock (sck) synchronizes shifting and sampling of the information on the two serial data lines. a slave select line allows selection of an individual slave spi device; slave devices that are not selected do not interfere with spi bus activities. optionally, on a master spi device, the slave select line can be used to indicate multiple-master bus contention. figure 21-11. master/slave transfer block diagram 1. n depends on the selected transfer width, please refer to section 21.3.2.2, ?pi control register 2 (spicr2) shift register shift register baud rate generator master spi slave spi mosi mosi miso miso sck sck ss ss v dd
serial peripheral interface (s12spiv5) mc9s12g family reference manual, rev.1.23 freescale semiconductor 721 21.4.3.1 clock phase and polarity controls using two bits in the spi control register 1, software selects one of four combinations of serial clock phase and polarity. the cpol clock polarity control bit speci?s an active high or low clock and has no signi?ant effect on the transmission format. the cpha clock phase control bit selects one of two fundamentally different transmission formats. clock phase and polarity should be identical for the master spi device and the communicating slave device. in some cases, the phase and polarity are changed between transmissions to allow a master device to communicate with peripheral slaves having different requirements. 21.4.3.2 cpha = 0 transfer format the ?st edge on the sck line is used to clock the ?st data bit of the slave into the master and the ?st data bit of the master into the slave. in some peripherals, the ?st bit of the slaves data is available at the slaves data out pin as soon as the slave is selected. in this format, the ?st sck edge is issued a half cycle after ss has become low. a half sck cycle later, the second edge appears on the sck line. when this second edge occurs, the value previously latched from the serial data input pin is shifted into the lsb or msb of the shift register, depending on lsbfe bit. after this second edge, the next bit of the spi master data is transmitted out of the serial data output pin of the master to the serial input pin on the slave. this process continues for a total of 16 edges on the sck line, with data being latched on odd numbered edges and shifted on even numbered edges. data reception is double buffered. data is shifted serially into the spi shift register during the transfer and is transferred to the parallel spi data register after the last bit is shifted in. after 2n 1 (last) sck edges: data that was previously in the master spi data register should now be in the slave data register and the data that was in the slave data register should be in the master. the spif ?g in the spi status register is set, indicating that the transfer is complete. figure 21-12 is a timing diagram of an spi transfer where cpha = 0. sck waveforms are shown for cpol = 0 and cpol = 1. the diagram may be interpreted as a master or slave timing diagram because the sck, miso, and mosi pins are connected directly between the master and the slave. the miso signal is the output from the slave and the mosi signal is the output from the master. the ss pin of the master must be either high or recon?ured as a general-purpose output not affecting the spi. 1. n depends on the selected transfer width, please refer to section 21.3.2.2, ?pi control register 2 (spicr2)
serial peripheral interface (s12spiv5) mc9s12g family reference manual, rev.1.23 722 freescale semiconductor figure 21-12. spi clock format 0 (cpha = 0), with 8-bit transfer width selected (xfrw = 0) t l begin end sck (cpol = 0) sample i change o sel ss (o) transfer sck (cpol = 1) msb ?st (lsbfe = 0): lsb ?st (lsbfe = 1): msb lsb lsb msb bit 5 bit 2 bit 6 bit 1 bit 4 bit 3 bit 3 bit 4 bit 2 bit 5 bit 1 bit 6 change o sel ss (i) mosi pin miso pin master only mosi/miso t t if next transfer begins here for t t , t l , t l minimum 1/2 sck t i t l t l = minimum leading time before the ?st sck edge t t = minimum trailing time after the last sck edge t i = minimum idling time between transfers (minimum ss high time) t l , t t , and t i are guaranteed for the master mode and required for the slave mode. 1 2 34 56 78910111213141516 sck edge number end of idle state begin of idle state
serial peripheral interface (s12spiv5) mc9s12g family reference manual, rev.1.23 freescale semiconductor 723 figure 21-13. spi clock format 0 (cpha = 0), with 16-bit transfer width selected (xfrw = 1) in slave mode, if the ss line is not deasserted between the successive transmissions then the content of the spi data register is not transmitted; instead the last received data is transmitted. if the ss line is deasserted for at least minimum idle time (half sck cycle) between successive transmissions, then the content of the spi data register is transmitted. in master mode, with slave select output enabled the ss line is always deasserted and reasserted between successive transfers for at least minimum idle time. 21.4.3.3 cpha = 1 transfer format some peripherals require the ?st sck edge before the ?st data bit becomes available at the data out pin, the second edge clocks data into the system. in this format, the ?st sck edge is issued by setting the cpha bit at the beginning of the n 1 -cycle transfer operation. the ?st edge of sck occurs immediately after the half sck clock cycle synchronization delay. this ?st edge commands the slave to transfer its ?st data bit to the serial data input pin of the master. 1. n depends on the selected transfer width, please refer to section 21.3.2.2, ?pi control register 2 (spicr2) t l begin end sck (cpol = 0) sample i change o sel ss (o) transfer sck (cpol = 1) msb ?st (lsbfe = 0) lsb ?st (lsbfe = 1) msb lsb lsb msb bit 13 bit 2 bit 14 bit 1 bit 12 bit 3 bit 11 bit 4 bit 5 change o sel ss (i) mosi pin miso pin master only mosi/miso t t if next transfer begins here for t t , t l , t l minimum 1/2 sck t i t l t l = minimum leading time before the ?st sck edge t t = minimum trailing time after the last sck edge t i = minimum idling time between transfers (minimum ss high time) t l , t t , and t i are guaranteed for the master mode and required for the slave mode. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 sck edge number end of idle state begin of idle state 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 bit 10 bit 9 bit 8 bit 7 bit 6 bit 4 bit 3 bit 2 bit 1 bit 6 bit 5 bit 7 bit 8 bit 9 bit 10bit 11 bit 12bit 13 bit 14
serial peripheral interface (s12spiv5) mc9s12g family reference manual, rev.1.23 724 freescale semiconductor a half sck cycle later, the second edge appears on the sck pin. this is the latching edge for both the master and slave. when the third edge occurs, the value previously latched from the serial data input pin is shifted into the lsb or msb of the spi shift register, depending on lsbfe bit. after this edge, the next bit of the master data is coupled out of the serial data output pin of the master to the serial input pin on the slave. this process continues for a total of n 1 edges on the sck line with data being latched on even numbered edges and shifting taking place on odd numbered edges. data reception is double buffered, data is serially shifted into the spi shift register during the transfer and is transferred to the parallel spi data register after the last bit is shifted in. after 2n 1 sck edges: data that was previously in the spi data register of the master is now in the data register of the slave, and data that was in the data register of the slave is in the master. the spif ?g bit in spisr is set indicating that the transfer is complete. figure 21-14 shows two clocking variations for cpha = 1. the diagram may be interpreted as a master or slave timing diagram because the sck, miso, and mosi pins are connected directly between the master and the slave. the miso signal is the output from the slave, and the mosi signal is the output from the master. the ss line is the slave select input to the slave. the ss pin of the master must be either high or recon?ured as a general-purpose output not affecting the spi.
serial peripheral interface (s12spiv5) mc9s12g family reference manual, rev.1.23 freescale semiconductor 725 figure 21-14. spi clock format 1 (cpha = 1), with 8-bit transfer width selected (xfrw = 0) t l t t for t t , t l , t l minimum 1/2 sck t i t l if next transfer begins here begin end sck (cpol = 0) sample i change o sel ss (o) transfer sck (cpol = 1) msb ?st (lsbfe = 0): lsb ?st (lsbfe = 1): msb lsb lsb msb bit 5 bit 2 bit 6 bit 1 bit 4 bit 3 bit 3 bit 4 bit 2 bit 5 bit 1 bit 6 change o sel ss (i) mosi pin miso pin master only mosi/miso t l = minimum leading time before the ?st sck edge, not required for back-to-back transfers t t = minimum trailing time after the last sck edge t i = minimum idling time between transfers (minimum ss high time), not required for back-to-back transfers 1 2 34 56 78910111213141516 sck edge number end of idle state begin of idle state
serial peripheral interface (s12spiv5) mc9s12g family reference manual, rev.1.23 726 freescale semiconductor figure 21-15. spi clock format 1 (cpha = 1), with 16-bit transfer width selected (xfrw = 1) the ss line can remain active low between successive transfers (can be tied low at all times). this format is sometimes preferred in systems having a single ?ed master and a single slave that drive the miso data line. back-to-back transfers in master mode in master mode, if a transmission has completed and new data is available in the spi data register, this data is sent out immediately without a trailing and minimum idle time. the spi interrupt request ?g (spif) is common to both the master and slave modes. spif gets set one half sck cycle after the last sck edge. 21.4.4 spi baud rate generation baud rate generation consists of a series of divider stages. six bits in the spi baud rate register (sppr2, sppr1, sppr0, spr2, spr1, and spr0) determine the divisor to the spi module clock which results in the spi baud rate. the spi clock rate is determined by the product of the value in the baud rate preselection bits (sppr2?ppr0) and the value in the baud rate selection bits (spr2?pr0). the module clock divisor equation is shown in equation 21-3 . t l begin end sck (cpol = 0) sample i change o sel ss (o) transfer sck (cpol = 1) msb ?st (lsbfe = 0) lsb ?st (lsbfe = 1) msb lsb lsb msb bit 13 bit 2 bit 14 bit 1 bit 12 bit 3 bit 11 bit 4 bit 5 change o sel ss (i) mosi pin miso pin master only mosi/miso t t if next transfer begins here for t t , t l , t l minimum 1/2 sck t i t l t l = minimum leading time before the ?st sck edge, not required for back-to-back transfers t t = minimum trailing time after the last sck edge t i = minimum idling time between transfers (minimum ss high time), not required for back-to-back transfers 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 sck edge number end of idle state begin of idle state 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 bit 10 bit 9 bit 8 bit 7 bit 6 bit 4 bit 3 bit 2 bit 1 bit 6 bit 5 bit 7 bit 8 bit 9 bit 10bit 11 bit 12bit 13 bit 14
serial peripheral interface (s12spiv5) mc9s12g family reference manual, rev.1.23 freescale semiconductor 727 baudratedivisor = (sppr + 1) ? 2 (spr + 1) eqn. 21-3 when all bits are clear (the default condition), the spi module clock is divided by 2. when the selection bits (spr2?pr0) are 001 and the preselection bits (sppr2?ppr0) are 000, the module clock divisor becomes 4. when the selection bits are 010, the module clock divisor becomes 8, etc. when the preselection bits are 001, the divisor determined by the selection bits is multiplied by 2. when the preselection bits are 010, the divisor is multiplied by 3, etc. see table 21-6 for baud rate calculations for all bit conditions, based on a 25 mhz bus clock. the two sets of selects allows the clock to be divided by a non-power of two to achieve other baud rates such as divide by 6, divide by 10, etc. the baud rate generator is activated only when the spi is in master mode and a serial transfer is taking place. in the other cases, the divider is disabled to decrease i dd current. note for maximum allowed baud rates, please refer to the spi electrical speci?ation in the electricals chapter of this data sheet. 21.4.5 special features 21.4.5.1 ss output the ss output feature automatically drives the ss pin low during transmission to select external devices and drives it high during idle to deselect external devices. when ss output is selected, the ss output pin is connected to the ss input pin of the external device. the ss output is available only in master mode during normal spi operation by asserting ssoe and modfen bit as shown in table 21-2 . the mode fault feature is disabled while ss output is enabled. note care must be taken when using the ss output feature in a multimaster system because the mode fault feature is not available for detecting system errors between masters. 21.4.5.2 bidirectional mode (momi or siso) the bidirectional mode is selected when the spc0 bit is set in spi control register 2 (see table 21-10 ). in this mode, the spi uses only one serial data pin for the interface with external device(s). the mstr bit decides which pin to use. the mosi pin becomes the serial data i/o (momi) pin for the master mode, and the miso pin becomes serial data i/o (siso) pin for the slave mode. the miso pin in master mode and mosi pin in slave mode are not used by the spi.
serial peripheral interface (s12spiv5) mc9s12g family reference manual, rev.1.23 728 freescale semiconductor the direction of each serial i/o pin depends on the bidiroe bit. if the pin is con?ured as an output, serial data from the shift register is driven out on the pin. the same pin is also the serial input to the shift register. the sck is output for the master mode and input for the slave mode. the ss is the input or output for the master mode, and it is always the input for the slave mode. the bidirectional mode does not affect sck and ss functions. note in bidirectional master mode, with mode fault enabled, both data pins miso and mosi can be occupied by the spi, though mosi is normally used for transmissions in bidirectional mode and miso is not used by the spi. if a mode fault occurs, the spi is automatically switched to slave mode. in this case miso becomes occupied by the spi and mosi is not used. this must be considered, if the miso pin is used for another purpose. 21.4.6 error conditions the spi has one error condition: mode fault error 21.4.6.1 mode fault error if the ss input becomes low while the spi is con?ured as a master, it indicates a system error where more than one master may be trying to drive the mosi and sck lines simultaneously. this condition is not permitted in normal operation, the modf bit in the spi status register is set automatically, provided the modfen bit is set. in the special case where the spi is in master mode and modfen bit is cleared, the ss pin is not used by the spi. in this special case, the mode fault error function is inhibited and modf remains cleared. in case table 21-10. normal mode and bidirectional mode when spe = 1 master mode mstr = 1 slave mode mstr = 0 normal mode spc0 = 0 bidirectional mode spc0 = 1 spi mosi miso serial out serial in spi mosi miso serial in serial out spi momi serial out serial in bidiroe spi siso serial in serial out bidiroe
serial peripheral interface (s12spiv5) mc9s12g family reference manual, rev.1.23 freescale semiconductor 729 the spi system is con?ured as a slave, the ss pin is a dedicated input pin. mode fault error doesnt occur in slave mode. if a mode fault error occurs, the spi is switched to slave mode, with the exception that the slave output buffer is disabled. so sck, miso, and mosi pins are forced to be high impedance inputs to avoid any possibility of con?ct with another output driver. a transmission in progress is aborted and the spi is forced into idle state. if the mode fault error occurs in the bidirectional mode for a spi system con?ured in master mode, output enable of the momi (mosi in bidirectional mode) is cleared if it was set. no mode fault error occurs in the bidirectional mode for spi system con?ured in slave mode. the mode fault ?g is cleared automatically by a read of the spi status register (with modf set) followed by a write to spi control register 1. if the mode fault ?g is cleared, the spi becomes a normal master or slave again. note if a mode fault error occurs and a received data byte is pending in the receive shift register, this data byte will be lost. 21.4.7 low power mode options 21.4.7.1 spi in run mode in run mode with the spi system enable (spe) bit in the spi control register clear, the spi system is in a low-power, disabled state. spi registers remain accessible, but clocks to the core of this module are disabled. 21.4.7.2 spi in wait mode spi operation in wait mode depends upon the state of the spiswai bit in spi control register 2. if spiswai is clear, the spi operates normally when the cpu is in wait mode if spiswai is set, spi clock generation ceases and the spi module enters a power conservation state when the cpu is in wait mode. if spiswai is set and the spi is configured for master, any transmission and reception in progress stops at wait mode entry. the transmission and reception resumes when the spi exits wait mode. if spiswai is set and the spi is configured as a slave, any transmission and reception in progress continues if the sck continues to be driven from the master. this keeps the slave synchronized to the master and the sck. if the master transmits several bytes while the slave is in wait mode, the slave will continue to send out bytes consistent with the operation mode at the start of wait mode (i.e., if the slave is currently sending its spidr to the master, it will continue to send the same byte. else if the slave is currently sending the last received byte from the master, it will continue to send each previous master byte).
serial peripheral interface (s12spiv5) mc9s12g family reference manual, rev.1.23 730 freescale semiconductor note care must be taken when expecting data from a master while the slave is in wait or stop mode. even though the shift register will continue to operate, the rest of the spi is shut down (i.e., a spif interrupt will not be generated until exiting stop or wait mode). also, the byte from the shift register will not be copied into the spidr register until after the slave spi has exited wait or stop mode. in slave mode, a received byte pending in the receive shift register will be lost when entering wait or stop mode. an spif ?g and spidr copy is generated only if wait mode is entered or exited during a tranmission. if the slave enters wait mode in idle mode and exits wait mode in idle mode, neither a spif nor a spidr copy will occur. 21.4.7.3 spi in stop mode stop mode is dependent on the system. the spi enters stop mode when the module clock is disabled (held high or low). if the spi is in master mode and exchanging data when the cpu enters stop mode, the transmission is frozen until the cpu exits stop mode. after stop, data to and from the external spi is exchanged correctly. in slave mode, the spi will stay synchronized with the master. the stop mode is not dependent on the spiswai bit. 21.4.7.4 reset the reset values of registers and signals are described in section 21.3, ?emory map and register de?ition , which details the registers and their bit ?lds. if a data transmission occurs in slave mode after reset without a write to spidr, it will transmit garbage, or the data last received from the master before the reset. reading from the spidr after reset will always read zeros. 21.4.7.5 interrupts the spi only originates interrupt requests when spi is enabled (spe bit in spicr1 set). the following is a description of how the spi makes a request and how the mcu should acknowledge that request. the interrupt vector offset and interrupt priority are chip dependent. the interrupt ?gs modf, spif, and sptef are logically ored to generate an interrupt request. 21.4.7.5.1 modf modf occurs when the master detects an error on the ss pin. the master spi must be con?ured for the modf feature (see table 21-2 ). after modf is set, the current transfer is aborted and the following bit is changed: mstr = 0, the master bit in spicr1 resets. the modf interrupt is re?cted in the status register modf ?g. clearing the ?g will also clear the interrupt. this interrupt will stay active while the modf ?g is set. modf has an automatic clearing process which is described in section 21.3.2.4, ?pi status register (spisr) .
serial peripheral interface (s12spiv5) mc9s12g family reference manual, rev.1.23 freescale semiconductor 731 21.4.7.5.2 spif spif occurs when new data has been received and copied to the spi data register. after spif is set, it does not clear until it is serviced. spif has an automatic clearing process, which is described in section 21.3.2.4, ?pi status register (spisr) . 21.4.7.5.3 sptef sptef occurs when the spi data register is ready to accept new data. after sptef is set, it does not clear until it is serviced. sptef has an automatic clearing process, which is described in section 21.3.2.4, ?pi status register (spisr) .
serial peripheral interface (s12spiv5) mc9s12g family reference manual, rev.1.23 732 freescale semiconductor
mc9s12g family reference manual, rev.1.23 freescale semiconductor 733 chapter 22 timer module (tim16b6cv3) 22.1 introduction the basic scalable timer consists of a 16-bit, software-programmable counter driven by a ?xible programmable prescaler. this timer can be used for many purposes, including input waveform measurements while simultaneously generating an output waveform. this timer could contain up to 6 input capture/output compare channels . the input capture function is used to detect a selected transition edge and record the time. the output compare function is used for generating output signals or for timer software delays. a full access for the counter registers or the input capture/output compare registers should take place in one clock cycle. accessing high byte and low byte separately for all of these registers may not yield the same result as accessing them in one word. 22.1.1 features the tim16b6cv3 includes these distinctive features: up to 6 channels available. (refer to device speci?ation for exact number) all channels have same input capture/output compare functionality. clock prescaling. 16-bit counter. 22.1.2 modes of operation stop: timer is off because clocks are stopped. table 22-1. v03.00 jan. 28, 2009 initial version v03.01 aug. 26, 2009 22.1.2/22-733 22.3.2.2/22-737 , 22.4.3/22-749 - correct typo: tscr ->tscr1; - correct typo: ectxxx->timxxx v03.02 apri,12,2010 22.3.2.6/22-740 22.3.2.9/22-742 22.4.3/22-749 -update tcre bit description v03.03 jan,14,2013 -single source generate different channel guide
timer module (tim16b6cv3) mc9s12g family reference manual, rev.1.23 734 freescale semiconductor freeze: timer counter keeps on running, unless tsfrz in tscr1 is set to 1. wait: counters keeps on running, unless tswai in tscr1 is set to 1. normal: timer counter keep on running, unless ten in tscr1 is cleared to 0. 22.1.3 block diagrams figure 22-1. tim16b6cv3 block diagram prescaler 16-bit counter input capture output compare ioc0 ioc2 ioc1 ioc5 ioc3 ioc4 timer over?w interrupt timer channel 0 interrupt timer channel 4 interrupt registers bus clock input capture output compare input capture output compare input capture output compare input capture output compare input capture output compare channel 0 channel 1 channel 2 channel 3 channel 4 channel 5 timer channel 1 interrupt timer channel 2 interrupt timer channel 3 interrupt timer channel 5 interrupt
timer module (tim16b6cv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 735 figure 22-2. interrupt flag setting 22.2 external signal description the tim16b6cv3 module has a selected number of external pins. refer to device speci?ation for exact number. 22.2.1 ioc5 - ioc0 ?input capture and output compare channel 5-0 those pins serve as input capture or output compare for tim16b6cv3 channel . note for the description of interrupts see section 22.6, ?nterrupts . 22.3 memory map and register de?ition this section provides a detailed description of all memory and registers. 22.3.1 module memory map the memory map for the tim16b6cv3 module is given below in figure 22-3 . the address listed for each register is the address offset. the total address for each register is the sum of the base address for the tim16b6cv3 module and the address offset for each register. 22.3.2 register descriptions this section consists of register descriptions in address order. each description includes a standard register diagram with an associated ?ure number. details of register bit and ?ld function follow the register diagrams, in bit order. iocn edge detector 16-bit main timer tcn input capture reg. set cnf interrupt
timer module (tim16b6cv3) mc9s12g family reference manual, rev.1.23 736 freescale semiconductor only bits related to implemented channels are valid. register name bit 7 654321 bit 0 0x0000 tios r reserve d reserve d ios5 ios4 ios3 ios2 ios1 ios0 w 0x0001 cforc r00000000 w reserve d reserve d foc5 foc4 foc3 foc2 foc1 foc0 0x0004 tcnth r tcnt15 tcnt14 tcnt13 tcnt12 tcnt11 tcnt10 tcnt9 tcnt8 w 0x0005 tcntl r tcnt7 tcnt6 tcnt5 tcnt4 tcnt3 tcnt2 tcnt1 tcnt0 w 0x0006 tscr1 r ten tswai tsfrz tffca prnt 000 w 0x0007 ttov r reserve d reserve d tov5 tov4 tov3 tov2 tov1 tov0 w 0x0008 tctl1 r reserve d reserve d reserve d reserve d om5 ol5 om4 ol4 w 0x0009 tctl2 r om3 ol3 om2 ol2 om1 ol1 om0 ol0 w 0x000a tctl3 r reserve d reserve d reserve d reserve d edg5b edg5a edg4b edg4a w 0x000b tctl4 r edg3b edg3a edg2b edg2a edg1b edg1a edg0b edg0a w 0x000c tie r reserve d reserve d c5i c4i c3i c2i c1i c0i w 0x000d tscr2 r toi 000 reserve d pr2 pr1 pr0 w 0x000e tflg1 r reserve d reserve d c5f c4f c3f c2f c1f c0f w 0x000f tflg2 r tof 0000000 w 0x0010?x001f tcxh?cxl 1 r bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 w r bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 w 0x0024?x002b reserved r w 0x002c ocpd r reserve d reserve d ocpd5 ocpd4 ocpd3 ocpd2 ocpd1 ocpd0 w 0x002d reserved r 0x002e ptpsr r ptps7 ptps6 ptps5 ptps4 ptps3 ptps2 ptps1 ptps0 w 0x002f reserved r w figure 22-3. tim16b6cv3 register summary
timer module (tim16b6cv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 737 22.3.2.1 timer input capture/output compare select (tios) read: anytime write: anytime 22.3.2.2 timer compare force register (cforc) read: anytime but will always return 0x0000 (1 state is transient) write: anytime 1 the register is available only if corresponding channel exists. module base + 0x0000 76543210 r reserved reserved ios5 ios4 ios3 ios2 ios1 ios0 w reset 00000000 figure 22-4. timer input capture/output compare select (tios) table 22-2. tios field descriptions note: writing to unavailable bits has no effect. reading from unavailable bits return a zero. field description 5:0 ios[5:0] input capture or output compare channel con?uration 0 the corresponding implemented channel acts as an input capture. 1 the corresponding implemented channel acts as an output compare. module base + 0x0001 76543210 r00000000 w reserved reserved foc5 foc4 foc3 foc2 foc1 foc0 reset 00000000 figure 22-5. timer compare force register (cforc) table 22-3. cforc field descriptions note: writing to unavailable bits has no effect. reading from unavailable bits return a zero. field description 5:0 foc[5:0] note: force output compare action for channel 5 :0 ?a write to this register with the corresponding data bit(s) set causes the action which is programmed for output compare ? to occur immediately. the action taken is the same as if a successful comparison had just taken place with the tcx register except the interrupt ?g does not get set. if forced output compare on any channel occurs at the same time as the successful output compare then forced output compare action will take precedence and interrupt ?g won? get set.
timer module (tim16b6cv3) mc9s12g family reference manual, rev.1.23 738 freescale semiconductor 22.3.2.3 timer count register (tcnt) the 16-bit main timer is an up counter. a full access for the counter register should take place in one clock cycle. a separate read/write for high byte and low byte will give a different result than accessing them as a word. read: anytime write: has no meaning or effect in the normal mode; only writable in special modes (test_mode = 1). the period of the ?st count after a write to the tcnt registers may be a different size because the write is not synchronized with the prescaler clock. 22.3.2.4 timer system control register 1 (tscr1) read: anytime write: anytime module base + 0x0004 15 14 13 12 11 10 9 9 r tcnt15 tcnt14 tcnt13 tcnt12 tcnt11 tcnt10 tcnt9 tcnt8 w reset 00000000 figure 22-6. timer count register high (tcnth) module base + 0x0005 76543210 r tcnt7 tcnt6 tcnt5 tcnt4 tcnt3 tcnt2 tcnt1 tcnt0 w reset 00000000 figure 22-7. timer count register low (tcntl) module base + 0x0006 76543210 r ten tswai tsfrz tffca prnt 000 w reset 00000000 = unimplemented or reserved figure 22-8. timer system control register 1 (tscr1)
timer module (tim16b6cv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 739 22.3.2.5 timer toggle on over?w register 1 (ttov) read: anytime write: anytime table 22-4. tscr1 field descriptions field description 7 ten timer enable 0 disables the main timer, including the counter. can be used for reducing power consumption. 1 allows the timer to function normally. if for any reason the timer is not active, there is no 64 clock for the pulse accumulator because the 64 is generated by the timer prescaler. 6 tswai timer module stops while in wait 0 allows the timer module to continue running during wait. 1 disables the timer module when the mcu is in the wait mode. timer interrupts cannot be used to get the mcu out of wait. tswai also affects pulse accumulator. 5 tsfrz timer stops while in freeze mode 0 allows the timer counter to continue running while in freeze mode. 1 disables the timer counter whenever the mcu is in freeze mode. this is useful for emulation. tsfrz does not stop the pulse accumulator. 4 tffca timer fast flag clear all 0 allows the timer ?g clearing to function normally. 1 for tflg1(0x000e), a read from an input capture or a write to the output compare channel (0x0010?x001f) causes the corresponding channel ?g, cnf, to be cleared. for tflg2 (0x000f), any access to the tcnt register (0x0004, 0x0005) clears the tof ?g. this has the advantage of eliminating software overhead in a separate clear sequence. extra care is required to avoid accidental ?g clearing due to unintended accesses. 3 prnt precision timer 0 enables legacy timer. pr0, pr1, and pr2 bits of the tscr2 register are used for timer counter prescaler selection. 1 enables precision timer. all bits of the ptpsr register are used for precision timer prescaler selection, and all bits. this bit is writable only once out of reset. module base + 0x0007 76543210 r reserved reserved tov5 tov4 tov3 tov2 tov1 tov0 w reset 00000000 figure 22-9. timer toggle on over?w register 1 (ttov)
timer module (tim16b6cv3) mc9s12g family reference manual, rev.1.23 740 freescale semiconductor 22.3.2.6 timer control register 1/timer control register 2 (tctl1/tctl2) read: anytime write: anytime table 22-5. ttov field descriptions note: writing to unavailable bits has no effect. reading from unavailable bits return a zero. field description 5:0 tov[5:0] toggle on over?w bits tovx toggles output compare pin on over?w. this feature only takes effect when in output compare mode. when set, it takes precedence over forced output compare 0 toggle output compare pin on over?w feature disabled. 1 toggle output compare pin on over?w feature enabled. module base + 0x0008 76543210 r reserved reserved reserved reserved om5 ol5 om4 ol4 w reset 00000000 figure 22-10. timer control register 1 (tctl1) module base + 0x0009 76543210 r om3 ol3 om2 ol2 om1 ol1 om0 ol0 w reset 00000000 figure 22-11. timer control register 2 (tctl2) table 22-6. tctl1/tctl2 field descriptions note: writing to unavailable bits has no effect. reading from unavailable bits return a zero field description 5:0 omx output mode these six pairs of control bits are encoded to specify the output action to be taken as a result of a successful ocx compare. when either omx or olx is 1, the pin associated with ocx becomes an output tied to ocx. note: for an output line to be driven by an ocx the ocpdx must be cleared. 5:0 olx output level ?these sixpairs of control bits are encoded to specify the output action to be taken as a result of a successful ocx compare. when either omx or olx is 1, the pin associated with ocx becomes an output tied to ocx. note: for an output line to be driven by an ocx the ocpdx must be cleared.
timer module (tim16b6cv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 741 22.3.2.7 timer control register 3/timer control register 4 (tctl3 and tctl4) read: anytime write: anytime. table 22-7. compare result output action omx olx action 0 0 no output compare action on the timer output signal 0 1 toggle ocx output line 1 0 clear ocx output line to zero 1 1 set ocx output line to one module base + 0x000a 76543210 r reserved reserved reserved reserved edg5b edg5a edg4b edg4a w reset 00000000 figure 22-12. timer control register 3 (tctl3) module base + 0x000b 76543210 r edg3b edg3a edg2b edg2a edg1b edg1a edg0b edg0a w reset 00000000 figure 22-13. timer control register 4 (tctl4) table 22-8. tctl3/tctl4 field descriptions note: writing to unavailable bits has no effect. reading from unavailable bits return a zero. field description 5:0 edgnb edgna input capture edge control these six pairs of control bits con?ure the input capture edge detector circuits. table 22-9. edge detector circuit con?uration edgnb edgna con?uration 0 0 capture disabled 0 1 capture on rising edges only 1 0 capture on falling edges only
timer module (tim16b6cv3) mc9s12g family reference manual, rev.1.23 742 freescale semiconductor 22.3.2.8 timer interrupt enable register (tie) read: anytime write: anytime. 22.3.2.9 timer system control register 2 (tscr2) read: anytime write: anytime. 1 1 capture on any edge (rising or falling) module base + 0x000c 76543210 r reserved reserved c5i c4i c3i c2i c1i c0i w reset 00000000 figure 22-14. timer interrupt enable register (tie) table 22-10. tie field descriptions note: writing to unavailable bits has no effect. reading from unavailable bits return a zero field description 5:0 c5i:c0i input capture/output compare ??interrupt enable the bits in tie correspond bit-for-bit with the bits in the tflg1 status register. if cleared, the corresponding ?g is disabled from causing a hardware interrupt. if set, the corresponding ?g is enabled to cause a interrupt. module base + 0x000d 76543210 r toi 000 reserved pr2 pr1 pr0 w reset 00000000 = unimplemented or reserved figure 22-15. timer system control register 2 (tscr2) table 22-9. edge detector circuit con?uration edgnb edgna con?uration
timer module (tim16b6cv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 743 note the newly selected prescale factor will not take effect until the next synchronized edge where all prescale counter stages equal zero. 22.3.2.10 main timer interrupt flag 1 (tflg1) read: anytime write: used in the clearing mechanism (set bits cause corresponding bits to be cleared). writing a zero will not affect current status of the bit. table 22-11. tscr2 field descriptions field description 7 toi timer over?w interrupt enable 0 interrupt inhibited. 1 hardware interrupt requested when tof ?g set. 2 pr[2:0] timer prescaler select ?these three bits select the frequency of the timer prescaler clock derived from the bus clock as shown in table 22-12 . table 22-12. timer clock selection pr2 pr1 pr0 timer clock 0 0 0 bus clock / 1 0 0 1 bus clock / 2 0 1 0 bus clock / 4 0 1 1 bus clock / 8 1 0 0 bus clock / 16 1 0 1 bus clock / 32 1 1 0 bus clock / 64 1 1 1 bus clock / 128 module base + 0x000e 76543210 r reserved reserved c5f c4f c3f c2f c1f c0f w reset 00000000 figure 22-16. main timer interrupt flag 1 (tflg1)
timer module (tim16b6cv3) mc9s12g family reference manual, rev.1.23 744 freescale semiconductor 22.3.2.11 main timer interrupt flag 2 (tflg2) tflg2 indicates when interrupt conditions have occurred. to clear a bit in the ?g register, write the bit to one while ten bit of tscr1 . read: anytime write: used in clearing mechanism (set bits cause corresponding bits to be cleared). any access to tcnt will clear tflg2 register if the tffca bit in tscr register is set. table 22-13. trlg1 field descriptions note: writing to unavailable bits has no effect. reading from unavailable bits return a zero. field description 5:0 c[5:0]f input capture/output compare channel ??flag ?these flags are set when an input capture or output compare event occurs. clearing requires writing a one to the corresponding ?g bit while ten is set to one. note: when tffca bit in tscr register is set, a read from an input capture or a write into an output compare channel (0x0010?x001f) will cause the corresponding channel ?g cxf to be cleared. module base + 0x000f 76543210 r tof 0000000 w reset 00000000 unimplemented or reserved figure 22-17. main timer interrupt flag 2 (tflg2) table 22-14. trlg2 field descriptions field description 7 tof timer over?w flag set when 16-bit free-running timer over?ws from 0xffff to 0x0000. clearing this bit requires writing a one to bit 7 of tflg2 register while the ten bit of tscr1 is set to one (see also tcre control bit explanation.)
timer module (tim16b6cv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 745 22.3.2.12 timer input capture/output compare registers high and low 0 5(tcxh and tcxl) 1 this register is available only when the corresponding channel exists and is reserved if that channel does not exist. writes to a reserved register have no functional effect. reads from a reserved register return zeroes. depending on the tios bit for the corresponding channel, these registers are used to latch the value of the free-running counter when a de?ed transition is sensed by the corresponding input capture edge detector or to trigger an output action for output compare. read: anytime write: anytime for output compare function.writes to these registers have no meaning or effect during input capture. all timer input capture/output compare registers are reset to 0x0000. note read/write access in byte mode for high byte should take place before low byte otherwise it will give a different result. module base + 0x0010 = tc0h 0x0012 = tc1h 0x0014=tc2h 0x0016=tc3h 0x0018=tc4h 0x001a=tc5h 0x001c=reservd 0x001e=reservd 15 14 13 12 11 10 9 0 r bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 w reset 00000000 figure 22-18. timer input capture/output compare register x high (tcxh) module base + 0x0011 = tc0l 0x0013 = tc1l 0x0015 =tc2l 0x0017=tc3l 0x0019 =tc4l 0x001b=tc5l 0x001d=reservd 0x001f=reservd 76543210 r bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 w reset 00000000 figure 22-19. timer input capture/output compare register x low (tcxl)
timer module (tim16b6cv3) mc9s12g family reference manual, rev.1.23 746 freescale semiconductor 22.3.2.13 output compare pin disconnect register(ocpd) read: anytime write: anytime all bits reset to zero. 22.3.2.14 precision timer prescaler select register (ptpsr) read: anytime write: anytime all bits reset to zero. module base + 0x002c 76543210 r reserved reserved ocpd5 ocpd4 ocpd3 ocpd2 ocpd1 ocpd0 w reset 00000000 figure 22-20. output compare pin disconnect register (ocpd) table 22-15. ocpd field description note: writing to unavailable bits has no effect. reading from unavailable bits return a zero. field description ocpd[5:0] output compare pin disconnect bits 0 enables the timer channel port. output compare action will occur on the channel pin. these bits do not affect the input capture or pulse accumulator functions 1 disables the timer channel port. output compare action will not occur on the channel pin, but the output compare ?g still become set. module base + 0x002e 76543210 r ptps7 ptps6 ptps5 ptps4 ptps3 ptps2 ptps1 ptps0 w reset 00000000 figure 22-21. precision timer prescaler select register (ptpsr)
timer module (tim16b6cv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 747 ... the prescaler can be calculated as follows depending on logical value of the ptps[7:0] and prnt bit: prnt = 1 : prescaler = ptps[7:0] + 1 table 22-17. precision timer prescaler selection examples when prnt = 1 22.4 functional description this section provides a complete functional description of the timer tim16b6cv3 block. please refer to the detailed timer block diagram in figure 22-22 as necessary. table 22-16. ptpsr field descriptions field description 7:0 ptps[7:0] precision timer prescaler select bits these eight bits specify the division rate of the main timer prescaler. these are effective only when the prnt bit of tscr1 is set to 1. table 22-17 shows some selection examples in this case. the newly selected prescale factor will not take effect until the next synchronized edge where all prescale counter stages equal zero. ptps7 ptps6 ptps5 ptps4 ptps3 ptps2 ptps1 ptps0 prescale factor 00000000 1 00000001 2 00000010 3 00000011 4 -------- - -------- - -------- - 00010011 20 00010100 21 00010101 22 -------- - -------- - -------- - 11111100 253 11111101 254 11111110 255 11111111 256
timer module (tim16b6cv3) mc9s12g family reference manual, rev.1.23 748 freescale semiconductor figure 22-22. detailed timer block diagram 22.4.1 prescaler the prescaler divides the bus clock by 1, 2, 4, 8, 16, 32, 64 or 128. the prescaler select bits, pr[2:0], select the prescaler divisor. pr[2:0] are in timer system control register 2 (tscr2). the prescaler divides the bus clock by a prescalar value. prescaler select bits pr[2:0] of in timer system control register 2 (tscr2) are set to de?e a prescalar value that generates a divide by 1, 2, 4, 8, 16, 32, 64 and 128 when the prnt bit in tscr1 is disabled. prescaler channel 0 ioc0 pin 16-bit counter logic pr[2:1:0] tc0 16-bit comparator tcnt(hi):tcnt(lo) channel 1 tc1 16-bit comparator interrupt logic tof toi c0f c1f edge detect ioc1 pin logic edge detect cxf channeln-1 tcn-1 16-bit comparator cn-1f iocn-1 pin logic edge detect om:ol0 tov0 om:ol1 tov1 om:ol7 tov7 edg1a edg1b edg7a edg7b edg0b cxi ch. n-1compare ch.n-1 capture ch. 1 capture mux clk[1:0] paclk paclk/256 paclk/65536 ioc1 pin ioc0 pin iocn-1 pin te ch. 1 compare ch. 0compare ch. 0 capture pa input channel2 edg0a ioc0 ioc1 iocn-1 tof c0f c1f cn-1f mux pre-prescaler ptpsr[7:0] bus clock 1 0 prnt n is channels number.
timer module (tim16b6cv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 749 by enabling the prnt bit of the tscr1 register, the performance of the timer can be enhanced. in this case, it is possible to set additional prescaler settings for the main timer counter in the present timer by using ptpsr[7:0] bits of ptpsr register generating divide by 1, 2, 3, 4,....20, 21, 22, 23,......255, or 256. 22.4.2 input capture clearing the i/o (input/output) select bit, iosx, con?ures channel x as an input capture channel. the input capture function captures the time at which an external event occurs. when an active edge occurs on the pin of an input capture channel, the timer transfers the value in the timer counter into the timer channel registers, tcx. the minimum pulse width for the input capture input is greater than two bus clocks. an input capture on channel x sets the cxf ?g. the cxi bit enables the cxf ?g to generate interrupt requests. timer module must stay enabled (ten bit of tscr1 register must be set to one) while clearing cxf (writing one to cxf). 22.4.3 output compare setting the i/o select bit, iosx, con?ures channel x when available as an output compare channel. the output compare function can generate a periodic pulse with a programmable polarity, duration, and frequency. when the timer counter reaches the value in the channel registers of an output compare channel, the timer can set, clear, or toggle the channel pin if the corresponding ocpdx bit is set to zero. an output compare on channel x sets the cxf ?g. the cxi bit enables the cxf ?g to generate interrupt requests. timer module must stay enabled (ten bit of tscr1 register must be set to one) while clearing cxf (writing one to cxf). the output mode and level bits, omx and olx, select set, clear, toggle on output compare. clearing both omx and olx results in no output compare action on the output compare channel pin. setting a force output compare bit, focx, causes an output compare on channel x. a forced output compare does not set the channel ?g. writing to the timer port bit of an output compare pin does not affect the pin state. the value written is stored in an internal latch. when the pin becomes available for general-purpose output, the last value written to the bit appears at the pin. 22.4.3.1 oc channel initialization the internal register whose output drives ocx can be programmed before the timer drives ocx. the desired state can be programmed to this internal register by writing a one to cforcx bit with tiosx, ocpdx and ten bits set to one. set ocx: write a 1 to focx while ten=1, iosx=1, omx=1, olx=1 and ocpdx=1 clear ocx: write a 1 to focx while ten=1, iosx=1, omx=1, olx=0 and ocpdx=1
timer module (tim16b6cv3) mc9s12g family reference manual, rev.1.23 750 freescale semiconductor setting ocpdx to zero allows the internal register to drive the programmed state to ocx. this allows a glitch free switch over of port from general purpose i/o to timer output once the ocpdx bit is set to zero. 22.5 resets the reset state of each individual bit is listed within section 22.3, ?emory map and register de?ition which details the registers and their bit ?lds 22.6 interrupts this section describes interrupts originated by the tim16b6cv3 block. table 22-18 lists the interrupts generated by the tim16b6cv3 to communicate with the mcu. the tim16b6cv3 could use up to 7 interrupt vectors. the interrupt vector offsets and interrupt numbers are chip dependent. 22.6.1 channel [5:0] interrupt (c[5:0]f) this active high outputs will be asserted by the module to request a timer channel 7 0 interrupt. the tim block only generates the interrupt and does not service it. only bits related to implemented channels are valid. 22.6.2 timer over?w interrupt (tof) this active high output will be asserted by the module to request a timer over?w interrupt. the tim block only generates the interrupt and does not service it. table 22-18. tim16b6cv3 interrupts interrupt offset vector priority source description c[5:0]f timer channel 5? active high timer channel interrupts 5? tof timer over?w timer over?w interrupt
mc9s12g family reference manual, rev.1.23 freescale semiconductor 751 chapter 23 timer module (tim16b8cv3) 23.1 introduction the basic scalable timer consists of a 16-bit, software-programmable counter driven by a ?xible programmable prescaler. this timer can be used for many purposes, including input waveform measurements while simultaneously generating an output waveform. pulse widths can vary from microseconds to many seconds. this timer could contain up to 8 input capture/output compare channels with one pulse accumulator available only on channel 7. the input capture function is used to detect a selected transition edge and record the time. the output compare function is used for generating output signals or for timer software delays. the 16-bit pulse accumulator is used to operate as a simple event counter or a gated time accumulator. the pulse accumulator shares timer channel 7 when the channel is available and when in event mode. a full access for the counter registers or the input capture/output compare registers should take place in one clock cycle. accessing high byte and low byte separately for all of these registers may not yield the same result as accessing them in one word. 23.1.1 features the tim16b8cv3 includes these distinctive features: up to 8 channels available. (refer to device speci?ation for exact number) table 23-1. v03.00 jan. 28, 2009 initial version v03.01 aug. 26, 2009 23.1.2/23-752 figure 23-4./23- 755 23.3.2.15/23-76 8 23.3.2.2/23-758 , 23.3.2.3/23-758 , 23.3.2.4/23-759 , 23.4.3/23-774 - correct typo: tscr ->tscr1; - correct typo: ectxxx->timxxx - correct reference: figure 23-25 -> figure 23-30 - add description, ? counter over?w when ttov[7] is set? to be the condition of channel 7 override event. - phrase the description of oc7m to make it more explicit v03.02 apri,12,2010 23.3.2.8/23-762 23.3.2.11/23-76 5 23.4.3/23-774 -add table 23-10 -update tcre bit description -add figure 23-31 v03.03 jan,14,2013 -single source generate different channel guide
timer module (tim16b8cv3) mc9s12g family reference manual, rev.1.23 752 freescale semiconductor all channels have same input capture/output compare functionality. clock prescaling. 16-bit counter. 16-bit pulse accumulator on channel 7 . 23.1.2 modes of operation stop: timer is off because clocks are stopped. freeze: timer counter keeps on running, unless tsfrz in tscr1 is set to 1. wait: counters keeps on running, unless tswai in tscr1 is set to 1. normal: timer counter keep on running, unless ten in tscr1 is cleared to 0. 23.1.3 block diagrams
timer module (tim16b8cv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 753 figure 23-1. tim16b8cv3 block diagram prescaler 16-bit counter input capture output compare 16-bit pulse accumulator ioc0 ioc2 ioc1 ioc5 ioc3 ioc4 ioc6 ioc7 pa input interrupt pa over?w interrupt timer over?w interrupt timer channel 0 interrupt timer channel 7 interrupt registers bus clock input capture output compare input capture output compare input capture output compare input capture output compare input capture output compare input capture output compare input capture output compare channel 0 channel 1 channel 2 channel 3 channel 4 channel 5 channel 6 channel 7 maximum possible channels, scalable from 0 to 7. pulse accumulator is available only if channel 7 exists.
timer module (tim16b8cv3) mc9s12g family reference manual, rev.1.23 754 freescale semiconductor figure 23-2. 16-bit pulse accumulator block diagram figure 23-3. interrupt flag setting edge detector intermodule bus ioc7 m clock divide by 64 clock select clk0 clk1 4:1 mux timclk paclk paclk / 256 paclk / 65536 prescaled clock (pclk) (timer clock) interrupt mux (pamod) pacnt iocn edge detector 16-bit main timer tcn input capture reg. set cnf interrupt
timer module (tim16b8cv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 755 figure 23-4. channel 7 output compare/pulse accumulator logic 23.2 external signal description the tim16b8cv3 module has a selected number of external pins. refer to device speci?ation for exact number. 23.2.1 ioc7 ?input capture and output compare channel 7 this pin serves as input capture or output compare for channel 7 . this can also be con?ured as pulse accumulator input. 23.2.2 ioc6 - ioc0 ?input capture and output compare channel 6-0 those pins serve as input capture or output compare for tim16b8cv3 channel . note for the description of interrupts see section 23.6, ?nterrupts . 23.3 memory map and register de?ition this section provides a detailed description of all memory and registers. 23.3.1 module memory map the memory map for the tim16b8cv3 module is given below in figure 23-5 . the address listed for each register is the address offset. the total address for each register is the sum of the base address for the tim16b8cv3 module and the address offset for each register. pulse accumulator pa d ten channel 7 output compare ocpd tios7
timer module (tim16b8cv3) mc9s12g family reference manual, rev.1.23 756 freescale semiconductor 23.3.2 register descriptions this section consists of register descriptions in address order. each description includes a standard register diagram with an associated ?ure number. details of register bit and ?ld function follow the register diagrams, in bit order. only bits related to implemented channels are valid. register name bit 7 654321 bit 0 0x0000 tios r ios7 ios6 ios5 ios4 ios3 ios2 ios1 ios0 w 0x0001 cforc r00000000 w foc7 foc6 foc5 foc4 foc3 foc2 foc1 foc0 0x0002 oc7m r oc7m7 oc7m6 oc7m5 oc7m4 oc7m3 oc7m2 oc7m1 oc7m0 w 0x0003 oc7d r oc7d7 oc7d6 oc7d5 oc7d4 oc7d3 oc7d2 oc7d1 oc7d0 w 0x0004 tcnth r tcnt15 tcnt14 tcnt13 tcnt12 tcnt11 tcnt10 tcnt9 tcnt8 w 0x0005 tcntl r tcnt7 tcnt6 tcnt5 tcnt4 tcnt3 tcnt2 tcnt1 tcnt0 w 0x0006 tscr1 r ten tswai tsfrz tffca prnt 000 w 0x0007 ttov r tov7 tov6 tov5 tov4 tov3 tov2 tov1 tov0 w 0x0008 tctl1 r om7 ol7 om6 ol6 om5 ol5 om4 ol4 w 0x0009 tctl2 r om3 ol3 om2 ol2 om1 ol1 om0 ol0 w 0x000a tctl3 r edg7b edg7a edg6b edg6a edg5b edg5a edg4b edg4a w 0x000b tctl4 r edg3b edg3a edg2b edg2a edg1b edg1a edg0b edg0a w 0x000c tie r c7i c6i c5i c4i c3i c2i c1i c0i w 0x000d tscr2 r toi 000 tcre pr2 pr1 pr0 w 0x000e tflg1 r c7f c6f c5f c4f c3f c2f c1f c0f w 0x000f tflg2 r tof 0000000 w 0x0010?x001f tcxh?cxl 1 r bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 w r bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 w 0x0020 pactl r0 paen pamod pedge clk1 clk0 paovi pai w figure 23-5. tim16b8cv3 register summary (sheet 1 of 2)
timer module (tim16b8cv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 757 23.3.2.1 timer input capture/output compare select (tios) read: anytime write: anytime 0x0021 paflg r000000 paovf paif w 0x0022 pacnth r pacnt15 pacnt14 pacnt13 pacnt12 pacnt11 pacnt10 pacnt9 pacnt8 w 0x0023 pacntl r pacnt7 pacnt6 pacnt5 pacnt4 pacnt3 pacnt2 pacnt1 pacnt0 w 0x0024?x002b reserved r w 0x002c ocpd r ocpd7 ocpd6 ocpd5 ocpd4 ocpd3 ocpd2 ocpd1 ocpd0 w 0x002d reserved r 0x002e ptpsr r ptps7 ptps6 ptps5 ptps4 ptps3 ptps2 ptps1 ptps0 w 0x002f reserved r w 1 the register is available only if corresponding channel exists. module base + 0x0000 76543210 r ios7 ios6 ios5 ios4 ios3 ios2 ios1 ios0 w reset 00000000 figure 23-6. timer input capture/output compare select (tios) table 23-2. tios field descriptions note: writing to unavailable bits has no effect. reading from unavailable bits return a zero. field description 7:0 ios[7:0] input capture or output compare channel con?uration 0 the corresponding implemented channel acts as an input capture. 1 the corresponding implemented channel acts as an output compare. register name bit 7 654321 bit 0 figure 23-5. tim16b8cv3 register summary (sheet 2 of 2)
timer module (tim16b8cv3) mc9s12g family reference manual, rev.1.23 758 freescale semiconductor 23.3.2.2 timer compare force register (cforc) read: anytime but will always return 0x0000 (1 state is transient) write: anytime 23.3.2.3 output compare 7 mask register (oc7m) read: anytime write: anytime module base + 0x0001 76543210 r00000000 w foc7 foc6 foc5 foc4 foc3 foc2 foc1 foc0 reset 00000000 figure 23-7. timer compare force register (cforc) table 23-3. cforc field descriptions note: writing to unavailable bits has no effect. reading from unavailable bits return a zero. field description 7:0 foc[7:0] note: force output compare action for channel 7 :0 ?a write to this register with the corresponding data bit(s) set causes the action which is programmed for output compare ? to occur immediately. the action taken is the same as if a successful comparison had just taken place with the tcx register except the interrupt ?g does not get set. a channel 7 event, which can be a counter over?w when ttov[7] is set or a successful output compare on channel 7, overrides any channel 6:0 compares. if forced output compare on any channel occurs at the same time as the successful output compare then forced output compare action will take precedence and interrupt ?g won? get set. module base + 0x0002 76543210 r oc7m7 oc7m6 oc7m5 oc7m4 oc7m3 oc7m2 oc7m1 oc7m0 w reset 00000000 figure 23-8. output compare 7 mask register (oc7m)
timer module (tim16b8cv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 759 23.3.2.4 output compare 7 data register (oc7d) 1 . read: anytime write: anytime 23.3.2.5 timer count register (tcnt) table 23-4. oc7m field descriptions field description 7:0 oc7m[7:0] output compare 7 mask ?a channel 7 event, which can be a counter over?w when ttov[7] is set or a successful output compare on channel 7, overrides any channel 6:0 compares. for each oc7m bit that is set, the output compare action re?cts the corresponding oc7d bit. 0 the corresponding oc7dx bit in the output compare 7 data register will not be transferred to the timer port on a channel 7 event, even if the corresponding pin is setup for output compare. 1 the corresponding oc7dx bit in the output compare 7 data register will be transferred to the timer port on a channel 7 event. note: the corresponding channel must also be setup for output compare (iosx = 1 and ocpdx = 0) for data to be transferred from the output compare 7 data register to the timer port. module base + 0x0003 76543210 r oc7d7 oc7d6 oc7d5 oc7d4 oc7d3 oc7d2 oc7d1 oc7d0 w reset 00000000 figure 23-9. output compare 7 data register (oc7d) table 23-5. oc7d field descriptions field description 7:0 oc7d[7:0] output compare 7 data ?a channel 7 event, which can be a counter over?w when ttov[7] is set or a successful output compare on channel 7, can cause bits in the output compare 7 data register to transfer to the timer port data register depending on the output compare 7 mask register. module base + 0x0004 15 14 13 12 11 10 9 9 r tcnt15 tcnt14 tcnt13 tcnt12 tcnt11 tcnt10 tcnt9 tcnt8 w reset 00000000 figure 23-10. timer count register high (tcnth)
timer module (tim16b8cv3) mc9s12g family reference manual, rev.1.23 760 freescale semiconductor the 16-bit main timer is an up counter. a full access for the counter register should take place in one clock cycle. a separate read/write for high byte and low byte will give a different result than accessing them as a word. read: anytime write: has no meaning or effect in the normal mode; only writable in special modes (test_mode = 1). the period of the ?st count after a write to the tcnt registers may be a different size because the write is not synchronized with the prescaler clock. 23.3.2.6 timer system control register 1 (tscr1) read: anytime write: anytime module base + 0x0005 76543210 r tcnt7 tcnt6 tcnt5 tcnt4 tcnt3 tcnt2 tcnt1 tcnt0 w reset 00000000 figure 23-11. timer count register low (tcntl) module base + 0x0006 76543210 r ten tswai tsfrz tffca prnt 000 w reset 00000000 = unimplemented or reserved figure 23-12. timer system control register 1 (tscr1) table 23-6. tscr1 field descriptions field description 7 ten timer enable 0 disables the main timer, including the counter. can be used for reducing power consumption. 1 allows the timer to function normally. if for any reason the timer is not active, there is no 64 clock for the pulse accumulator because the 64 is generated by the timer prescaler. 6 tswai timer module stops while in wait 0 allows the timer module to continue running during wait. 1 disables the timer module when the mcu is in the wait mode. timer interrupts cannot be used to get the mcu out of wait. tswai also affects pulse accumulator.
timer module (tim16b8cv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 761 23.3.2.7 timer toggle on over?w register 1 (ttov) read: anytime write: anytime 5 tsfrz timer stops while in freeze mode 0 allows the timer counter to continue running while in freeze mode. 1 disables the timer counter whenever the mcu is in freeze mode. this is useful for emulation. tsfrz does not stop the pulse accumulator. 4 tffca timer fast flag clear all 0 allows the timer ?g clearing to function normally. 1 for tflg1(0x000e), a read from an input capture or a write to the output compare channel (0x0010?x001f) causes the corresponding channel ?g, cnf, to be cleared. for tflg2 (0x000f), any access to the tcnt register (0x0004, 0x0005) clears the tof ?g. any access to the pacnt registers (0x0022, 0x0023) clears the paovf and paif ?gs in the paflg register (0x0021) if channel 7 exists. this has the advantage of eliminating software overhead in a separate clear sequence. extra care is required to avoid accidental ?g clearing due to unintended accesses. 3 prnt precision timer 0 enables legacy timer. pr0, pr1, and pr2 bits of the tscr2 register are used for timer counter prescaler selection. 1 enables precision timer. all bits of the ptpsr register are used for precision timer prescaler selection, and all bits. this bit is writable only once out of reset. module base + 0x0007 76543210 r tov7 tov6 tov5 tov4 tov3 tov2 tov1 tov0 w reset 00000000 figure 23-13. timer toggle on over?w register 1 (ttov) table 23-7. ttov field descriptions note: writing to unavailable bits has no effect. reading from unavailable bits return a zero. field description 7:0 tov[7:0] toggle on over?w bits tovx toggles output compare pin on over?w. this feature only takes effect when in output compare mode. when set, it takes precedence over forced output compare but not channel 7 override events. 0 toggle output compare pin on over?w feature disabled. 1 toggle output compare pin on over?w feature enabled. table 23-6. tscr1 field descriptions (continued) field description
timer module (tim16b8cv3) mc9s12g family reference manual, rev.1.23 762 freescale semiconductor 23.3.2.8 timer control register 1/timer control register 2 (tctl1/tctl2) read: anytime write: anytime module base + 0x0008 76543210 r om7 ol7 om6 ol6 om5 ol5 om4 ol4 w reset 00000000 figure 23-14. timer control register 1 (tctl1) module base + 0x0009 76543210 r om3 ol3 om2 ol2 om1 ol1 om0 ol0 w reset 00000000 figure 23-15. timer control register 2 (tctl2) table 23-8. tctl1/tctl2 field descriptions note: writing to unavailable bits has no effect. reading from unavailable bits return a zero field description 7:0 omx output mode these eight pairs of control bits are encoded to specify the output action to be taken as a result of a successful ocx compare. when either omx or olx is 1, the pin associated with ocx becomes an output tied to ocx. note: to enable output action by omx bits on timer port, the corresponding bit in oc7m should be cleared. for an output line to be driven by an ocx the ocpdx must be cleared. 7:0 olx output level these eightpairs of control bits are encoded to specify the output action to be taken as a result of a successful ocx compare. when either omx or olx is 1, the pin associated with ocx becomes an output tied to ocx. note: to enable output action by olx bits on timer port, the corresponding bit in oc7m should be cleared. for an output line to be driven by an ocx the ocpdx must be cleared. table 23-9. compare result output action omx olx action 0 0 no output compare action on the timer output signal 0 1 toggle ocx output line 1 0 clear ocx output line to zero 1 1 set ocx output line to one
timer module (tim16b8cv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 763 note: to enable output action using the om7 and ol7 bits on the timer port,the corresponding bit oc7m7 in the oc7m register must also be cleared. the settings for these bits can be seen in table 23-10 . note: in table 23-10 , the ios7 and iosx should be set to 1 iosx is the register tios bit x, oc7mx is the register oc7m bit x, tcx is timer input capture/output compare register, iocx is channel x, omx/olx is the register tctl1/tctl2, oc7dx is the register oc7d bit x. iocx = oc7dx+ omx/olx, means that both oc7 event and ocx event will change channel x value. 23.3.2.9 timer control register 3/timer control register 4 (tctl3 and tctl4) read: anytime table 23-10. the oc7 and ocx event priority oc7m7=0 oc7m7=1 oc7mx=1 oc7mx=0 oc7mx=1 oc7mx=0 tc7=tcx tc7>tcx tc7=tcx tc7>tcx tc7=tcx tc7>tcx tc7=tcx tc7>tcx iocx=oc7dx ioc7=om7/o l7 iocx=oc7dx +omx/olx ioc7=om7/o l7 iocx=omx/olx ioc7=om7/ol7 iocx=oc7dx ioc7=oc7d7 iocx=oc7dx +omx/olx ioc7=oc7d7 iocx=omx/olx ioc7=oc7d7 module base + 0x000a 76543210 r edg7b edg7a edg6b edg6a edg5b edg5a edg4b edg4a w reset 00000000 figure 23-16. timer control register 3 (tctl3) module base + 0x000b 76543210 r edg3b edg3a edg2b edg2a edg1b edg1a edg0b edg0a w reset 00000000 figure 23-17. timer control register 4 (tctl4)
timer module (tim16b8cv3) mc9s12g family reference manual, rev.1.23 764 freescale semiconductor write: anytime. 23.3.2.10 timer interrupt enable register (tie) read: anytime write: anytime. table 23-11. tctl3/tctl4 field descriptions note: writing to unavailable bits has no effect. reading from unavailable bits return a zero. field description 7:0 edgnb edgna input capture edge control ?these eight pairs of control bits con?ure the input capture edge detector circuits. table 23-12. edge detector circuit con?uration edgnb edgna con?uration 0 0 capture disabled 0 1 capture on rising edges only 1 0 capture on falling edges only 1 1 capture on any edge (rising or falling) module base + 0x000c 76543210 r c7i c6i c5i c4i c3i c2i c1i c0i w reset 00000000 figure 23-18. timer interrupt enable register (tie) table 23-13. tie field descriptions note: writing to unavailable bits has no effect. reading from unavailable bits return a zero field description 7:0 c7i:c0i input capture/output compare ??interrupt enable the bits in tie correspond bit-for-bit with the bits in the tflg1 status register. if cleared, the corresponding ?g is disabled from causing a hardware interrupt. if set, the corresponding ?g is enabled to cause a interrupt.
timer module (tim16b8cv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 765 23.3.2.11 timer system control register 2 (tscr2) read: anytime write: anytime. module base + 0x000d 76543210 r toi 000 tcre pr2 pr1 pr0 w reset 00000000 = unimplemented or reserved figure 23-19. timer system control register 2 (tscr2) table 23-14. tscr2 field descriptions field description 7 toi timer over?w interrupt enable 0 interrupt inhibited. 1 hardware interrupt requested when tof ?g set. 3 tcre timer counter reset enable this bit allows the timer counter to be reset by a successful output compare 7 event. this mode of operation is similar to an up-counting modulus counter. 0 counter reset inhibited and counter free runs. 1 counter reset by a successful output compare 7. note: if tc7 = 0x0000 and tcre = 1, tcnt will stay at 0x0000 continuously. if tc7 = 0xffff and tcre = 1, tof will never be set when tcnt is reset from 0xffff to 0x0000. note: tcre=1 and tc7!=0, the tcnt cycle period will be tc7 x "prescaler counter width" + "1 bus clock", for a more detail explanation please refer to section 23.4.3, ?utput compare note: this bit and feature is available only when channel 7 exists. if channel 7 doesn? exist, this bit is reserved. writing to reserved bit has no effect. read from reserved bit return a zero. 2 pr[2:0] timer prescaler select ?these three bits select the frequency of the timer prescaler clock derived from the bus clock as shown in table 23-15 . table 23-15. timer clock selection pr2 pr1 pr0 timer clock 0 0 0 bus clock / 1 0 0 1 bus clock / 2 0 1 0 bus clock / 4 0 1 1 bus clock / 8 1 0 0 bus clock / 16 1 0 1 bus clock / 32 1 1 0 bus clock / 64 1 1 1 bus clock / 128
timer module (tim16b8cv3) mc9s12g family reference manual, rev.1.23 766 freescale semiconductor note the newly selected prescale factor will not take effect until the next synchronized edge where all prescale counter stages equal zero. 23.3.2.12 main timer interrupt flag 1 (tflg1) read: anytime write: used in the clearing mechanism (set bits cause corresponding bits to be cleared). writing a zero will not affect current status of the bit. 23.3.2.13 main timer interrupt flag 2 (tflg2) tflg2 indicates when interrupt conditions have occurred. to clear a bit in the ?g register, write the bit to one while ten bit of tscr1 or paen bit of pactl is set to one. read: anytime write: used in clearing mechanism (set bits cause corresponding bits to be cleared). module base + 0x000e 76543210 r c7f c6f c5f c4f c3f c2f c1f c0f w reset 00000000 figure 23-20. main timer interrupt flag 1 (tflg1) table 23-16. trlg1 field descriptions note: writing to unavailable bits has no effect. reading from unavailable bits return a zero. field description 7:0 c[7:0]f input capture/output compare channel ??flag ?these flags are set when an input capture or output compare event occurs. clearing requires writing a one to the corresponding ?g bit while ten or paen is set to one. note: when tffca bit in tscr register is set, a read from an input capture or a write into an output compare channel (0x0010?x001f) will cause the corresponding channel ?g cxf to be cleared. module base + 0x000f 76543210 r tof 0000000 w reset 00000000 unimplemented or reserved figure 23-21. main timer interrupt flag 2 (tflg2)
timer module (tim16b8cv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 767 any access to tcnt will clear tflg2 register if the tffca bit in tscr register is set. 23.3.2.14 timer input capture/output compare registers high and low 0 7(tcxh and tcxl) 1 this register is available only when the corresponding channel exists and is reserved if that channel does not exist. writes to a reserved register have no functional effect. reads from a reserved register return zeroes. depending on the tios bit for the corresponding channel, these registers are used to latch the value of the free-running counter when a de?ed transition is sensed by the corresponding input capture edge detector or to trigger an output action for output compare. read: anytime write: anytime for output compare function.writes to these registers have no meaning or effect during input capture. all timer input capture/output compare registers are reset to 0x0000. note read/write access in byte mode for high byte should take place before low byte otherwise it will give a different result. table 23-17. trlg2 field descriptions field description 7 tof timer over?w flag set when 16-bit free-running timer over?ws from 0xffff to 0x0000. clearing this bit requires writing a one to bit 7 of tflg2 register while the ten bit of tscr1 or paen bit of pactl is set to one (see also tcre control bit explanation.) module base + 0x0010 = tc0h 0x0012 = tc1h 0x0014=tc2h 0x0016=tc3h 0x0018=tc4h 0x001a=tc5h 0x001c=tc6h 0x001e=tc7h 15 14 13 12 11 10 9 0 r bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 w reset 00000000 figure 23-22. timer input capture/output compare register x high (tcxh) module base + 0x0011 = tc0l 0x0013 = tc1l 0x0015 =tc2l 0x0017=tc3l 0x0019 =tc4l 0x001b=tc5l 0x001d=tc6l 0x001f=tc7l 76543210 r bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 w reset 00000000 figure 23-23. timer input capture/output compare register x low (tcxl)
timer module (tim16b8cv3) mc9s12g family reference manual, rev.1.23 768 freescale semiconductor 23.3.2.15 16-bit pulse accumulator control register (pactl) read: any time write: any time when paen is set, the pulse accumulator counter is enabled. the pulse accumulator counter shares the input pin with ioc7. module base + 0x0020 76543210 r0 paen pamod pedge clk1 clk0 paovi pai w reset 00000000 unimplemented or reserved figure 23-24. 16-bit pulse accumulator control register (pactl) table 23-18. pactl field descriptions field description 6 paen pulse accumulator system enable ?paen is independent from ten. with timer disabled, the pulse accumulator can function unless pulse accumulator is disabled. 0 16-bit pulse accumulator system disabled. 1 pulse accumulator system enabled. 5 pamod pulse accumulator mode ?this bit is active only when the pulse accumulator is enabled (paen = 1). see table 23-19 . 0 event counter mode. 1 gated time accumulation mode. 4 pedge pulse accumulator edge control this bit is active only when the pulse accumulator is enabled (paen = 1). for pamod bit = 0 (event counter mode). see table 23-19 . 0 falling edges on ioc7 pin cause the count to be increased. 1 rising edges on ioc7 pin cause the count to be increased. for pamod bit = 1 (gated time accumulation mode). 0 ioc7 input pin high enables m (bus clock) divided by 64 clock to pulse accumulator and the trailing falling edge on ioc7 sets the paif ?g. 1 ioc7 input pin low enables m (bus clock) divided by 64 clock to pulse accumulator and the trailing rising edge on ioc7 sets the paif ?g. 3:2 clk[1:0] clock select bits refer to table 23-20 . 1 paov i pulse accumulator over?w interrupt enable 0 interrupt inhibited. 1 interrupt requested if paovf is set. 0 pa i pulse accumulator input interrupt enable 0 interrupt inhibited. 1 interrupt requested if paif is set.
timer module (tim16b8cv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 769 note if the timer is not active (ten = 0 in tscr), there is no divide-by-64 because the 64 clock is generated by the timer prescaler. for the description of paclk please refer figure 23-30 . if the pulse accumulator is disabled (paen = 0), the prescaler clock from the timer is always used as an input clock to the timer counter. the change from one selected clock to the other happens immediately after these bits are written. 23.3.2.16 pulse accumulator flag register (paflg) 1 . read: anytime write: anytime when the tffca bit in the tscr register is set, any access to the pacnt register will clear all the ?gs in the paflg register. timer module or pulse accumulator must stay enabled (ten=1 or paen=1) while clearing these bits. table 23-19. pin action pamod pedge pin action 0 0 falling edge 0 1 rising edge 1 0 div. by 64 clock enabled with pin high level 1 1 div. by 64 clock enabled with pin low level table 23-20. timer clock selection clk1 clk0 timer clock 0 0 use timer prescaler clock as timer counter clock 0 1 use paclk as input to timer counter clock 1 0 use paclk/256 as timer counter clock frequency 1 1 use paclk/65536 as timer counter clock frequency module base + 0x0021 76543210 r000000 paovf paif w reset 00000000 unimplemented or reserved figure 23-25. pulse accumulator flag register (paflg)
timer module (tim16b8cv3) mc9s12g family reference manual, rev.1.23 770 freescale semiconductor 23.3.2.17 pulse accumulators count registers (pacnt) 1 . read: anytime write: anytime these registers contain the number of active input edges on its input pin since the last reset. when pacnt over?ws from 0xffff to 0x0000, the interrupt ?g paovf in paflg (0x0021) is set. full count register access should take place in one clock cycle. a separate read/write for high byte and low byte will give a different result than accessing them as a word. note readingthepulseaccumulatorcounterregistersimmediatelyafteranactiveedgeonthe pulseaccumulatorinputpinmaymissthelastcountbecausetheinputhastobesynchronized with the bus clock ?st. table 23-21. paflg field descriptions field description 1 paov f pulse accumulator over?w flag set when the 16-bit pulse accumulator over?ws from 0xffff to 0x0000. clearing this bit requires writing a one to this bit in the paflg register while ten bit of tscr1 or paen bit of pactl register is set to one. 0 paif pulse accumulator input edge flag set when the selected edge is detected at the ioc7 input pin.in event mode the event edge triggers paif and in gated time accumulation mode the trailing edge of the gate signal at the ioc7 input pin triggers paif. clearing this bit requires writing a one to this bit in the paflg register while ten bit of tscr1 or paen bit of pactl register is set to one. any access to the pacnt register will clear all the ?gs in this register when tffca bit in register tscr(0x0006) is set. module base + 0x0022 15 14 13 12 11 10 9 0 r pacnt15 pacnt14 pacnt13 pacnt12 pacnt11 pacnt10 pacnt9 pacnt8 w reset 00000000 figure 23-26. pulse accumulator count register high (pacnth) module base + 0x0023 76543210 r pacnt7 pacnt6 pacnt5 pacnt4 pacnt3 pacnt2 pacnt1 pacnt0 w reset 00000000 figure 23-27. pulse accumulator count register low (pacntl)
timer module (tim16b8cv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 771 23.3.2.18 output compare pin disconnect register(ocpd) read: anytime write: anytime all bits reset to zero. 23.3.2.19 precision timer prescaler select register (ptpsr) read: anytime write: anytime all bits reset to zero. module base + 0x002c 76543210 r ocpd7 ocpd6 ocpd5 ocpd4 ocpd3 ocpd2 ocpd1 ocpd0 w reset 00000000 figure 23-28. output compare pin disconnect register (ocpd) table 23-22. ocpd field description note: writing to unavailable bits has no effect. reading from unavailable bits return a zero. field description ocpd[7:0] output compare pin disconnect bits 0 enables the timer channel port. output compare action will occur on the channel pin. these bits do not affect the input capture or pulse accumulator functions 1 disables the timer channel port. output compare action will not occur on the channel pin, but the output compare ?g still become set. module base + 0x002e 76543210 r ptps7 ptps6 ptps5 ptps4 ptps3 ptps2 ptps1 ptps0 w reset 00000000 figure 23-29. precision timer prescaler select register (ptpsr)
timer module (tim16b8cv3) mc9s12g family reference manual, rev.1.23 772 freescale semiconductor ... the prescaler can be calculated as follows depending on logical value of the ptps[7:0] and prnt bit: prnt = 1 : prescaler = ptps[7:0] + 1 table 23-24. precision timer prescaler selection examples when prnt = 1 23.4 functional description this section provides a complete functional description of the timer tim16b8cv3 block. please refer to the detailed timer block diagram in figure 23-30 as necessary. table 23-23. ptpsr field descriptions field description 7:0 ptps[7:0] precision timer prescaler select bits these eight bits specify the division rate of the main timer prescaler. these are effective only when the prnt bit of tscr1 is set to 1. table 23-24 shows some selection examples in this case. the newly selected prescale factor will not take effect until the next synchronized edge where all prescale counter stages equal zero. ptps7 ptps6 ptps5 ptps4 ptps3 ptps2 ptps1 ptps0 prescale factor 00000000 1 00000001 2 00000010 3 00000011 4 -------- - -------- - -------- - 00010011 20 00010100 21 00010101 22 -------- - -------- - -------- - 11111100 253 11111101 254 11111110 255 11111111 256
timer module (tim16b8cv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 773 figure 23-30. detailed timer block diagram prescaler channel 0 ioc0 pin 16-bit counter logic pr[2:1:0] divide-by-64 tc0 edge detect pacnt(hi):pacnt(lo) paovf pedge paovi ten paen 16-bit comparator tcnt(hi):tcnt(lo) channel 1 tc1 16-bit comparator 16-bit counter interrupt logic tof toi c0f c1f edge detect ioc1 pin logic edge detect cxf channel7 tc7 16-bit comparator c7f ioc7 pin logic edge detect om:ol0 tov0 om:ol1 tov1 om:ol7 tov7 edg1a edg1b edg7a edg7b edg0b tcre paif clear counter paif pai interrupt logic cxi interrupt request paovf ch. 7 compare ch.7 capture ch. 1 capture mux clk[1:0] paclk paclk/256 paclk/65536 ioc1 pin ioc0 pin ioc7 pin paclk paclk/256 paclk/65536 te ch. 1 compare ch. 0compare ch. 0 capture pa input channel2 edg0a channel 7 output compare ioc0 ioc1 ioc7 bus clock paovf paovi tof c0f c1f c7f mux pre-prescaler ptpsr[7:0] bus clock 1 0 prnt maximum possible channels, scalable from 0 to 7. pulse accumulator is available only if channel 7 exists. mux pamod pedge
timer module (tim16b8cv3) mc9s12g family reference manual, rev.1.23 774 freescale semiconductor 23.4.1 prescaler the prescaler divides the bus clock by 1, 2, 4, 8, 16, 32, 64 or 128. the prescaler select bits, pr[2:0], select the prescaler divisor. pr[2:0] are in timer system control register 2 (tscr2). the prescaler divides the bus clock by a prescalar value. prescaler select bits pr[2:0] of in timer system control register 2 (tscr2) are set to de?e a prescalar value that generates a divide by 1, 2, 4, 8, 16, 32, 64 and 128 when the prnt bit in tscr1 is disabled. by enabling the prnt bit of the tscr1 register, the performance of the timer can be enhanced. in this case, it is possible to set additional prescaler settings for the main timer counter in the present timer by using ptpsr[7:0] bits of ptpsr register generating divide by 1, 2, 3, 4,....20, 21, 22, 23,......255, or 256. 23.4.2 input capture clearing the i/o (input/output) select bit, iosx, con?ures channel x as an input capture channel. the input capture function captures the time at which an external event occurs. when an active edge occurs on the pin of an input capture channel, the timer transfers the value in the timer counter into the timer channel registers, tcx. the minimum pulse width for the input capture input is greater than two bus clocks. an input capture on channel x sets the cxf ?g. the cxi bit enables the cxf ?g to generate interrupt requests. timer module or pulse accumulator must stay enabled (ten bit of tscr1 or paen bit of pactl register must be set to one) while clearing cxf (writing one to cxf). 23.4.3 output compare setting the i/o select bit, iosx, con?ures channel x when available as an output compare channel. the output compare function can generate a periodic pulse with a programmable polarity, duration, and frequency. when the timer counter reaches the value in the channel registers of an output compare channel, the timer can set, clear, or toggle the channel pin if the corresponding ocpdx bit is set to zero. an output compare on channel x sets the cxf ?g. the cxi bit enables the cxf ?g to generate interrupt requests. timer module or pulse accumulator must stay enabled (ten bit of tscr1 or paen bit of pactl register must be set to one) while clearing cxf (writing one to cxf). the output mode and level bits, omx and olx, select set, clear, toggle on output compare. clearing both omx and olx results in no output compare action on the output compare channel pin. setting a force output compare bit, focx, causes an output compare on channel x. a forced output compare does not set the channel ?g. a channel 7 event, which can be a counter over?w when ttov[7] is set or a successful output compare on channel 7, overrides output compares on all other output compare channels. the output compare 7 mask register masks the bits in the output compare 7 data register. the timer counter reset enable bit, tcre, enables channel 7 output compares to reset the timer counter. a channel 7 output compare can reset the timer counter even if the ioc7 pin is being used as the pulse accumulator input.
timer module (tim16b8cv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 775 writing to the timer port bit of an output compare pin does not affect the pin state. the value written is stored in an internal latch. when the pin becomes available for general-purpose output, the last value written to the bit appears at the pin. when tcre is set and tc7 is not equal to 0, then tcnt will cycle from 0 to tc7. when tcnt reaches tc7 value, it will last only one bus cycle then reset to 0. note: in figure 23-31 ,if pr[2:0] is equal to 0, one prescaler counter equal to one bus clock figure 23-31. the tcnt cycle diagram under tcre=1 condition 23.4.3.1 oc channel initialization the internal register whose output drives ocx can be programmed before the timer drives ocx. the desired state can be programmed to this internal register by writing a one to cforcx bit with tiosx, ocpdx and ten bits set to one. set ocx: write a 1 to focx while ten=1, iosx=1, omx=1, olx=1 and ocpdx=1 clear ocx: write a 1 to focx while ten=1, iosx=1, omx=1, olx=0 and ocpdx=1 setting ocpdx to zero allows the internal register to drive the programmed state to ocx. this allows a glitch free switch over of port from general purpose i/o to timer output once the ocpdx bit is set to zero. 23.4.4 pulse accumulator the pulse accumulator (pacnt) is a 16-bit counter that can operate in two modes: event counter mode ?counting edges of selected polarity on the pulse accumulator input pin, pai. gated time accumulation mode counting pulses from a divide-by-64 clock. the pamod bit selects the mode of operation. the minimum pulse width for the pai input is greater than two bus clocks. tc7 0 1 ----- tc7-1 tc7 0 tc7 event tc7 event prescaler counter 1 bus clock
timer module (tim16b8cv3) mc9s12g family reference manual, rev.1.23 776 freescale semiconductor 23.4.5 event counter mode clearing the pamod bit con?ures the pacnt for event counter operation. an active edge on the ioc7 pin increments the pulse accumulator counter. the pedge bit selects falling edges or rising edges to increment the count. note the pacnt input and timer channel 7 use the same pin ioc7. to use the ioc7, disconnect it from the output logic by clearing the channel 7 output mode and output level bits, om7 and ol7. also clear the channel 7 output compare 7 mask bit, oc7m7. the pulse accumulator counter register re?ct the number of active input edges on the pacnt input pin since the last reset. the paovf bit is set when the accumulator rolls over from 0xffff to 0x0000. the pulse accumulator over?w interrupt enable bit, paovi, enables the paovf ?g to generate interrupt requests. note the pulse accumulator counter can operate in event counter mode even when the timer enable bit, ten, is clear. 23.4.6 gated time accumulation mode setting the pamod bit con?ures the pulse accumulator for gated time accumulation operation. an active level on the pacnt input pin enables a divided-by-64 clock to drive the pulse accumulator. the pedge bit selects low levels or high levels to enable the divided-by-64 clock. the trailing edge of the active level at the ioc7 pin sets the paif. the pai bit enables the paif ?g to generate interrupt requests. the pulse accumulator counter register re?ct the number of pulses from the divided-by-64 clock since the last reset. note the timer prescaler generates the divided-by-64 clock. if the timer is not active, there is no divided-by-64 clock. 23.5 resets the reset state of each individual bit is listed within section 23.3, ?emory map and register de?ition which details the registers and their bit ?lds 23.6 interrupts this section describes interrupts originated by the tim16b8cv3 block. table 23-25 lists the interrupts generated by the tim16b8cv3 to communicate with the mcu.
timer module (tim16b8cv3) mc9s12g family reference manual, rev.1.23 freescale semiconductor 777 the tim16b8cv3 could use up to 11 interrupt vectors. the interrupt vector offsets and interrupt numbers are chip dependent. 23.6.1 channel [7:0] interrupt (c[7:0]f) this active high outputs will be asserted by the module to request a timer channel 7 0 interrupt. the tim block only generates the interrupt and does not service it. only bits related to implemented channels are valid. 23.6.2 pulse accumulator input interrupt (paovi) this active high output will be asserted by the module to request a timer pulse accumulator input interrupt. the tim block only generates the interrupt and does not service it. 23.6.3 pulse accumulator over?w interrupt (paovf) this active high output will be asserted by the module to request a timer pulse accumulator over?w interrupt. the tim block only generates the interrupt and does not service it. 23.6.4 timer over?w interrupt (tof) this active high output will be asserted by the module to request a timer over?w interrupt. the tim block only generates the interrupt and does not service it. table 23-25. tim16b8cv3 interrupts interrupt offset vector priority source description c[7:0]f timer channel 7? active high timer channel interrupts 7? paovi pulse accumulator input active high pulse accumulator input interrupt paovf pulse accumulator over?w pulse accumulator over?w interrupt tof timer over?w timer over?w interrupt
timer module (tim16b8cv3) mc9s12g family reference manual, rev.1.23 778 freescale semiconductor
mc9s12g family reference manual, rev.1.23 freescale semiconductor 779 chapter 24 16 kbyte flash module (s12ftmrg16k1v1) 24.1 introduction the ftmrg16k1 module implements the following: 16kbytes of p-flash (program flash) memory 512 bytes of eeprom memory the flash memory is ideal for single-supply applications allowing for ?ld reprogramming without requiring external high voltage sources for program or erase operations. the flash module includes a memory controller that executes commands to modify flash memory contents. the user interface to the memory controller consists of the indexed flash common command object (fccob) register which is written to with the command, global address, data, and any required command parameters. the memory controller must complete the execution of a command before the fccob register can be written to with a new command. caution a flash word or phrase must be in the erased state before being programmed. cumulative programming of bits within a flash word or phrase is not allowed. table 24-1. revision history revision number revision date sections affected description of changes v01.04 17 jun 2010 24.4.6.1/24-809 24.4.6.2/24-810 24.4.6.3/24-810 24.4.6.14/24-82 0 clarify erase verify commands descriptions related to the bits mgstat[1:0] of the register fstat. v01.05 20 aug 2010 24.4.6.2/24-810 24.4.6.12/24-81 7 24.4.6.13/24-81 9 updated description of the commands rd1blk, mloadu and mloadf rev.1.23 31 jan 2011 24.3.2.9/24-795 updated description of protection on section 24.3.2.9
mc9s12g family reference manual, rev.1.23 freescale semiconductor 780 the flash memory may be read as bytes and aligned words. read access time is one bus cycle for bytes and aligned words. for misaligned words access, the cpu has to perform twice the byte read access command. for flash memory, an erased bit reads 1 and a programmed bit reads 0. it is possible to read from p-flash memory while some commands are executing on eeprom memory. it is not possible to read from eeprom memory while a command is executing on p-flash memory. simultaneous p-flash and eeprom operations are discussed in section 24.4.5 . both p-flash and eeprom memories are implemented with error correction codes (ecc) that can resolve single bit faults and detect double bit faults. for p-flash memory, the ecc implementation requires that programming be done on an aligned 8 byte basis (a flash phrase). since p-flash memory is always read by half-phrase, only one single bit fault in an aligned 4 byte half-phrase containing the byte or word accessed will be corrected. 24.1.1 glossary command write sequence ?an mcu instruction sequence to execute built-in algorithms (including program and erase) on the flash memory. eeprom memory ?the eeprom memory constitutes the nonvolatile memory store for data. eeprom sector ?the eeprom sector is the smallest portion of the eeprom memory that can be erased. the eeprom sector consists of 4 bytes. nvm command mode an nvm mode using the cpu to setup the fccob register to pass parameters required for flash command execution. phrase ?an aligned group of four 16-bit words within the p-flash memory. each phrase includes two sets of aligned double words with each set including 7 ecc bits for single bit fault correction and double bit fault detection within each double word. p-flash memory the p-flash memory constitutes the main nonvolatile memory store for applications. p-flash sector ?the p-flash sector is the smallest portion of the p-flash memory that can be erased. each p-flash sector contains 512 bytes. program ifr ?nonvolatile information register located in the p-flash block that contains the version id, and the program once ?ld. 24.1.2 features 24.1.2.1 p-flash features 16 kbytes of p-flash memory composed of one 16 kbyte flash block divided into 32 sectors of 512 bytes
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 781 single bit fault correction and double bit fault detection within a 32-bit double word during read operations automated program and erase algorithm with verify and generation of ecc parity bits fast sector erase and phrase program operation ability to read the p-flash memory while programming a word in the eeprom memory flexible protection scheme to prevent accidental program or erase of p-flash memory 24.1.2.2 eeprom features 512 bytes of eeprom memory composed of one 512 byte flash block divided into 128 sectors of 4 bytes single bit fault correction and double bit fault detection within a word during read operations automated program and erase algorithm with verify and generation of ecc parity bits fast sector erase and word program operation protection scheme to prevent accidental program or erase of eeprom memory ability to program up to four words in a burst sequence 24.1.2.3 other flash module features no external high-voltage power supply required for flash memory program and erase operations interrupt generation on flash command completion and flash error detection security mechanism to prevent unauthorized access to the flash memory 24.1.3 block diagram the block diagram of the flash module is shown in figure 24-1 .
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 782 freescale semiconductor figure 24-1. ftmrg16k1 block diagram 24.2 external signal description the flash module contains no signals that connect off-chip. bus clock divider clock command interrupt request fclk protection security registers flash interface 16bit internal bus sector 0 sector 1 sector 31 4kx39 p-flash error interrupt request cpu 256x22 sector 0 sector 1 sector 127 eeprom memory controller
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 783 24.3 memory map and registers this section describes the memory map and registers for the flash module. read data from unimplemented memory space in the flash module is unde?ed. write access to unimplemented or reserved memory space in the flash module will be ignored by the flash module. caution writing to the flash registers while a flash command is executing (that is indicated when the value of ?g ccif reads as ?? is not allowed. if such action is attempted the write operation will not change the register value. writing to the flash registers is allowed when the flash is not busy executing commands (ccif = 1) and during initialization right after reset, despite the value of ?g ccif in that case (refer to section 24.6 for a complete description of the reset sequence). . 24.3.1 module memory map the s12 architecture places the p-flash memory between global addresses 0x3_c000 and 0x3_ffff as shown in table 24-3 .the p-flash memory map is shown in figure 24-2 . table 24-2. ftmrg memory map global address (in bytes) size (bytes) description 0x0_0000 - 0x0_03ff 1,024 register space 0x0_0400 ?0x0_05ff 512 eeprom memory 0x0_0600 ?0x0_07ff 512 ftmrg reserved area 0x0_4000 ?0x0_7fff 16,284 nvmres 1 =1 : nvm resource area (see figure 24-3 ) 1 see nvmres description in section 24.4.3 0x3_8000 ?0x3_bfff 16,384 ftmrg reserved area 0x3_c000 ?0x3_ffff 16,384 p-flash memory table 24-3. p-flash memory addressing global address size (bytes) description 0x3_c000 ?0x3_ffff 16 k p-flash block contains flash con?uration field (see table 24-4 )
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 784 freescale semiconductor the fprot register, described in section 24.3.2.9 , can be set to protect regions in the flash memory from accidental program or erase. two separate memory regions, one growing downward from global address 0x3_ffff in the flash memory (called the higher region), and the remaining addresses in the flash memory, can be activated for protection. the flash memory addresses covered by these protectable regions are shown in the p-flash memory map. the higher address region is mainly targeted to hold the boot loader code since it covers the vector space. default protection settings as well as security information that allows the mcu to restrict access to the flash module are stored in the flash con?uration ?ld as described in table 24-4 . figure 24-2. p-flash memory map table 24-4. flash con?uration field global address size (bytes) description 0x3_ff00-0x3_ff07 8 backdoor comparison key refer to section 24.4.6.11, ?erify backdoor access key command , and section 24.5.1, ?nsecuring the mcu using backdoor key access 0x3_ff08-0x3_ff0b 1 1 0x3ff08-0x3_ff0f form a flash phrase and must be programmed in a single command write sequence. each byte in the 0x3_ff08 - 0x3_ff0b reserved ?ld should be programmed to 0xff. 4 reserved 0x3_ff0c 1 1 p-flash protection byte . refer to section 24.3.2.9, ?-flash protection register (fprot) 0x3_ff0d 1 1 eeprom protection byte . refer to section 24.3.2.10, ?eprom protection register (eeprot) 0x3_ff0e 1 1 flash nonvolatile byte refer to section 24.3.2.16, ?lash option register (fopt) 0x3_ff0f 1 1 flash security byte refer to section 24.3.2.2, ?lash security register (fsec) flash con?uration field p-flash start = 0x3_c000 p-flash end = 0x3_ffff 0x3_f800 0x3_f000 0x3_e000 flash protected/unprotected higher region 2, 4, 8, 16 kbytes 16 bytes (0x3_ff00 - 0x3_ff0f) protection protection movable end fixed end
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 785 table 24-5. program ifr fields global address size (bytes) field description 0x0_4000 ?0x0_4007 8 reserved 0x0_4008 ?0x0_40b5 174 reserved 0x0_40b6 ?0x0_40b7 2 version id 1 1 used to track ?mware patch versions, see section 24.4.2 0x0_40b8 ?0x0_40bf 8 reserved 0x0_40c0 ?0x0_40ff 64 program once field refer to section 24.4.6.6, ?rogram once command table 24-6. memory controller resource fields (nvmres 1 =1) 1 nvmres - see section 24.4.3 for nvmres (nvm resource) detail. global address size (bytes) description 0x0_4000 ?0x040ff 256 p-flash ifr (see table 24-5 ) 0x0_4100 ?0x0_41ff 256 reserved. 0x0_4200 ?0x0_57ff reserved 0x0_5800 ?0x0_59ff 512 reserved 0x0_5a00 ?0x0_5fff 1,536 reserved 0x0_6000 ?0x0_6bff 3,072 reserved 0x0_6c00 ?0x0_7fff 5,120 reserved
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 786 freescale semiconductor figure 24-3. memory controller resource memory map (nvmres=1) 24.3.2 register descriptions the flash module contains a set of 20 control and status registers located between flash module base + 0x0000 and 0x0013. in the case of the writable registers, the write accesses are forbidden during fash command execution (for more detail, see caution note in section 24.3 ). a summary of the flash module registers is given in figure 24-4 with detailed descriptions in the following subsections. address & name 76543210 0x0000 fclkdiv r fdivld fdivlck fdiv5 fdiv4 fdiv3 fdiv2 fdiv1 fdiv0 w 0x0001 fsec r keyen1 keyen0 rnv5 rnv4 rnv3 rnv2 sec1 sec0 w 0x0002 fccobix r0 0 0 0 0 ccobix2 ccobix1 ccobix0 w figure 24-4. ftmrg16k1 register summary p-flash ifr 1 kbyte (nvmres=1) 0x0_4000 ram end = 0x0_59ff ram start = 0x0_5800 reserved 5120 bytes reserved 4608 bytes 0x0_6c00 0x0_7fff 0x0_4400 reserved 5k bytes reserved 512 bytes
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 787 0x0003 frsv0 r00000000 w 0x0004 fcnfg r ccie 00 ignsf 00 fdfd fsfd w 0x0005 fercnfg r0 0 0 0 0 0 dfdie sfdie w 0x0006 fstat r ccif 0 accerr fpviol mgbusy rsvd mgstat1 mgstat0 w 0x0007 ferstat r0 0 0 0 0 0 dfdif sfdif w 0x0008 fprot r fpopen rnv6 fphdis fphs1 fphs0 rnv2 rnv1 rnv0 w 0x0009 eeprot r dpopen 00 dps4 dps3 dps2 dps1 dps0 w 0x000a fccobhi r ccob15 ccob14 ccob13 ccob12 ccob11 ccob10 ccob9 ccob8 w 0x000b fccoblo r ccob7 ccob6 ccob5 ccob4 ccob3 ccob2 ccob1 ccob0 w 0x000c frsv1 r00000000 w 0x000d frsv2 r00000000 w 0x000e frsv3 r00000000 w 0x000f frsv4 r00000000 w 0x0010 fopt r nv7 nv6 nv5 nv4 nv3 nv2 nv1 nv0 w address & name 76543210 figure 24-4. ftmrg16k1 register summary (continued)
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 788 freescale semiconductor 24.3.2.1 flash clock divider register (fclkdiv) the fclkdiv register is used to control timed events in program and erase algorithms. all bits in the fclkdiv register are readable, bit 7 is not writable, bit 6 is write-once-hi and controls the writability of the fdiv ?ld in normal mode. in special mode, bits 6-0 are writable any number of times but bit 7 remains unwritable. caution the fclkdiv register should never be written while a flash command is executing (ccif=0). 0x0011 frsv5 r00000000 w 0x0012 frsv6 r00000000 w 0x0013 frsv7 r00000000 w = unimplemented or reserved offset module base + 0x0000 76543210 r fdivld fdivlck fdiv[5:0] w reset 00000000 = unimplemented or reserved figure 24-5. flash clock divider register (fclkdiv) table 24-7. fclkdiv field descriptions field description 7 fdivld clock divider loaded 0 fclkdiv register has not been written since the last reset 1 fclkdiv register has been written since the last reset address & name 76543210 figure 24-4. ftmrg16k1 register summary (continued)
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 789 24.3.2.2 flash security register (fsec) the fsec register holds all bits associated with the security of the mcu and flash module. 6 fdivlck clock divider locked 0 fdiv ?ld is open for writing 1 fdiv value is locked and cannot be changed. once the lock bit is set high, only reset can clear this bit and restore writability to the fdiv ?ld in normal mode. 5? fdiv[5:0] clock divider bits fdiv[5:0] must be set to effectively divide busclk down to 1 mhz to control timed events during flash program and erase algorithms. table 24-8 shows recommended values for fdiv[5:0] based on the busclk frequency. please refer to section 24.4.4, ?lash command operations , for more information. table 24-8. fdiv values for various busclk frequencies busclk frequency (mhz) fdiv[5:0] busclk frequency (mhz) fdiv[5:0] min 1 1 busclk is greater than this value. max 2 2 busclk is less than or equal to this value. min 1 max 2 1.0 1.6 0x00 16.6 17.6 0x10 1.6 2.6 0x01 17.6 18.6 0x11 2.6 3.6 0x02 18.6 19.6 0x12 3.6 4.6 0x03 19.6 20.6 0x13 4.6 5.6 0x04 20.6 21.6 0x14 5.6 6.6 0x05 21.6 22.6 0x15 6.6 7.6 0x06 22.6 23.6 0x16 7.6 8.6 0x07 23.6 24.6 0x17 8.6 9.6 0x08 24.6 25.6 0x18 9.6 10.6 0x09 10.6 11.6 0x0a 11.6 12.6 0x0b 12.6 13.6 0x0c 13.6 14.6 0x0d 14.6 15.6 0x0e 15.6 16.6 0x0f table 24-7. fclkdiv field descriptions (continued) field description
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 790 freescale semiconductor all bits in the fsec register are readable but not writable. during the reset sequence, the fsec register is loaded with the contents of the flash security byte in the flash con?uration ?ld at global address 0x3_ff0f located in p-flash memory (see table 24-4 ) as indicated by reset condition f in figure 24-6 . if a double bit fault is detected while reading the p-flash phrase containing the flash security byte during the reset sequence, all bits in the fsec register will be set to leave the flash module in a secured state with backdoor key access disabled. offset module base + 0x0001 76543210 r keyen[1:0] rnv[5:2] sec[1:0] w reset f 1 1 loaded from ifr flash con?uration ?ld, during reset sequence. f 1 f 1 f 1 f 1 f 1 f 1 f 1 = unimplemented or reserved figure 24-6. flash security register (fsec) table 24-9. fsec field descriptions field description 7? keyen[1:0] backdoor key security enable bits the keyen[1:0] bits de?e the enabling of backdoor key access to the flash module as shown in table 24-10 . 5? rnv[5:2] reserved nonvolatile bits ?the rnv bits should remain in the erased state for future enhancements. 1? sec[1:0] flash security bits ?the sec[1:0] bits de?e the security state of the mcu as shown in table 24-11 . if the flash module is unsecured using backdoor key access, the sec bits are forced to 10. table 24-10. flash keyen states keyen[1:0] status of backdoor key access 00 disabled 01 disabled 1 1 preferred keyen state to disable backdoor key access. 10 enabled 11 disabled table 24-11. flash security states sec[1:0] status of security 00 secured 01 secured 1 1 preferred sec state to set mcu to secured state. 10 unsecured 11 secured
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 791 the security function in the flash module is described in section 24.5 . 24.3.2.3 flash ccob index register (fccobix) the fccobix register is used to index the fccob register for flash memory operations. ccobix bits are readable and writable while remaining bits read 0 and are not writable. 24.3.2.4 flash reserved0 register (frsv0) this flash register is reserved for factory testing. all bits in the frsv0 register read 0 and are not writable. 24.3.2.5 flash con?uration register (fcnfg) the fcnfg register enables the flash command complete interrupt and forces ecc faults on flash array read access from the cpu. offset module base + 0x0002 76543210 r00000 ccobix[2:0] w reset 00000000 = unimplemented or reserved figure 24-7. fccob index register (fccobix) table 24-12. fccobix field descriptions field description 2? ccobix[1:0] common command register index the ccobix bits are used to select which word of the fccob register array is being read or written to. see 24.3.2.11 flash common command object register (fccob), for more details. offset module base + 0x000c 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 24-8. flash reserved0 register (frsv0)
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 792 freescale semiconductor ccie, ignsf, fdfd, and fsfd bits are readable and writable while remaining bits read 0 and are not writable. 24.3.2.6 flash error con?uration register (fercnfg) the fercnfg register enables the flash error interrupts for the ferstat ?gs. offset module base + 0x0004 76543210 r ccie 00 ignsf 00 fdfd fsfd w reset 00000000 = unimplemented or reserved figure 24-9. flash con?uration register (fcnfg) table 24-13. fcnfg field descriptions field description 7 ccie command complete interrupt enable ?the ccie bit controls interrupt generation when a flash command has completed. 0 command complete interrupt disabled 1 an interrupt will be requested whenever the ccif ?g in the fstat register is set (see section 24.3.2.7 ) 4 ignsf ignore single bit fault ?the ignsf controls single bit fault reporting in the ferstat register (see section 24.3.2.8 ). 0 all single bit faults detected during array reads are reported 1 single bit faults detected during array reads are not reported and the single bit fault interrupt will not be generated 1 fdfd force double bit fault detect the fdfd bit allows the user to simulate a double bit fault during flash array read operations and check the associated interrupt routine. the fdfd bit is cleared by writing a 0 to fdfd. 0 flash array read operations will set the dfdif ?g in the ferstat register only if a double bit fault is detected 1 any flash array read operation will force the dfdif ?g in the ferstat register to be set (see section 24.3.2.7 ) and an interrupt will be generated as long as the dfdie interrupt enable in the fercnfg register is set (see section 24.3.2.6 ) 0 fsfd force single bit fault detect the fsfd bit allows the user to simulate a single bit fault during flash array read operations and check the associated interrupt routine. the fsfd bit is cleared by writing a 0 to fsfd. 0 flash array read operations will set the sfdif ?g in the ferstat register only if a single bit fault is detected 1 flash array read operation will force the sfdif ?g in the ferstat register to be set (see section 24.3.2.7 ) and an interrupt will be generated as long as the sfdie interrupt enable in the fercnfg register is set (see section 24.3.2.6 )
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 793 all assigned bits in the fercnfg register are readable and writable. 24.3.2.7 flash status register (fstat) the fstat register reports the operational status of the flash module. ccif, accerr, and fpviol bits are readable and writable, mgbusy and mgstat bits are readable but not writable, while remaining bits read 0 and are not writable. offset module base + 0x0005 76543210 r000000 dfdie sfdie w reset 00000000 = unimplemented or reserved figure 24-10. flash error con?uration register (fercnfg) table 24-14. fercnfg field descriptions field description 1 dfdie double bit fault detect interrupt enable the dfdie bit controls interrupt generation when a double bit fault is detected during a flash block read operation. 0 dfdif interrupt disabled 1 an interrupt will be requested whenever the dfdif ?g is set (see section 24.3.2.8 ) 0 sfdie single bit fault detect interrupt enable the sfdie bit controls interrupt generation when a single bit fault is detected during a flash block read operation. 0 sfdif interrupt disabled whenever the sfdif ?g is set (see section 24.3.2.8 ) 1 an interrupt will be requested whenever the sfdif ?g is set (see section 24.3.2.8 ) offset module base + 0x0006 76543210 r ccif 0 accerr fpviol mgbusy rsvd mgstat[1:0] w reset 1000000 1 1 reset value can deviate from the value shown if a double bit fault is detected during the reset sequence (see section 24.6 ). 0 1 = unimplemented or reserved figure 24-11. flash status register (fstat)
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 794 freescale semiconductor 24.3.2.8 flash error status register (ferstat) the ferstat register re?cts the error status of internal flash operations. all ?gs in the ferstat register are readable and only writable to clear the ?g. table 24-15. fstat field descriptions field description 7 ccif command complete interrupt flag ?the ccif ?g indicates that a flash command has completed. the ccif ?g is cleared by writing a 1 to ccif to launch a command and ccif will stay low until command completion or command violation. 0 flash command in progress 1 flash command has completed 5 accerr flash access error flag ?the accerr bit indicates an illegal access has occurred to the flash memory caused by either a violation of the command write sequence (see section 24.4.4.2 ) or issuing an illegal flash command. while accerr is set, the ccif ?g cannot be cleared to launch a command. the accerr bit is cleared by writing a 1 to accerr. writing a 0 to the accerr bit has no effect on accerr. 0 no access error detected 1 access error detected 4 fpviol flash protection violation flag ?he fpviol bit indicates an attempt was made to program or erase an address in a protected area of p-flash or eeprom memory during a command write sequence. the fpviol bit is cleared by writing a 1 to fpviol. writing a 0 to the fpviol bit has no effect on fpviol. while fpviol is set, it is not possible to launch a command or start a command write sequence. 0 no protection violation detected 1 protection violation detected 3 mgbusy memory controller busy flag ?the mgbusy ?g re?cts the active state of the memory controller . 0 memory controller is idle 1 memory controller is busy executing a flash command (ccif = 0) 2 rsvd reserved bit ?this bit is reserved and always reads 0 . 1? mgstat[1:0] memory controller command completion status flag one or more mgstat ?g bits are set if an error is detected during execution of a flash command or during the flash reset sequence. see section 24.4.6, ?lash command description , and section 24.6, ?nitialization ?for details. offset module base + 0x0007 76543210 r000000 dfdif sfdif w reset 00000000 = unimplemented or reserved figure 24-12. flash error status register (ferstat)
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 795 24.3.2.9 p-flash protection register (fprot) the fprot register de?es which p-flash sectors are protected against program and erase operations. the (unreserved) bits of the fprot register are writable with the restriction that the size of the protected region can only be increased. while the rnv[2:0] bits are writable, they should be left in an erased state. during the reset sequence, the fprot register is loaded with the contents of the p-flash protection byte in the flash con?uration ?ld at global address 0x3_ff0c located in p-flash memory (see table 24-4 ) as indicated by reset condition ??in figure 24-13 . to change the p-flash protection that will be loaded during the reset sequence, the upper sector of the p-flash memory must be unprotected, then the p-flash protection byte must be reprogrammed. if a double bit fault is detected while reading the p-flash phrase containing the p-flash protection byte during the reset sequence, the fpopen bit will be cleared and remaining bits in the fprot register will be set to leave the p-flash memory fully protected. table 24-16. ferstat field descriptions field description 1 dfdif double bit fault detect interrupt flag ?the setting of the dfdif ?g indicates that a double bit fault was detected in the stored parity and data bits during a flash array read operation or that a flash array read operation returning invalid data was attempted on a flash block that was under a flash command operation. 1 the dfdif ?g is cleared by writing a 1 to dfdif. writing a 0 to dfdif has no effect on dfdif. 2 0 no double bit fault detected 1 double bit fault detected or a flash array read operation returning invalid data was attempted while command running 1 the single bit fault and double bit fault ?gs are mutually exclusive for parity errors (an ecc fault occurrence can be either single fault or double fault but never both). a simultaneous access collision (flash array read operation returning invalid data attempted while command running) is indicated when both sfdif and dfdif ?gs are high. 2 there is a one cycle delay in storing the ecc dfdif and sfdif fault ?gs in this register. at least one nop is required after a ?sh memory read before checking ferstat for the occurrence of ecc errors. 0 sfdif single bit fault detect interrupt flag ?with the ignsf bit in the fcnfg register clear, the sfdif ?g indicates that a single bit fault was detected in the stored parity and data bits during a flash array read operation or that a flash array read operation returning invalid data was attempted on a flash block that was under a flash command operation. 1 the sfdif ?g is cleared by writing a 1 to sfdif. writing a 0 to sfdif has no effect on sfdif. 0 no single bit fault detected 1 single bit fault detected and corrected or a flash array read operation returning invalid data was attempted while command running offset module base + 0x0008 76543210 r fpopen rnv6 fphdis fphs[1:0] rnv[2:0] w reset f 1 1 loaded from ifr flash con?uration ?ld, during reset sequence. f 1 f 1 f 1 f 1 f 1 f 1 f 1 = unimplemented or reserved figure 24-13. flash protection register (fprot)
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 796 freescale semiconductor trying to alter data in any protected area in the p-flash memory will result in a protection violation error and the fpviol bit will be set in the fstat register. the block erase of a p-flash block is not possible if any of the p-flash sectors contained in the same p-flash block are protected. although the protection scheme is loaded from the flash memory at global address 0x3_ff0c during the reset sequence, it can be changed by the user. the p-flash protection scheme can be used by applications requiring reprogramming in single chip mode while providing as much protection as possible if reprogramming is not required. table 24-17. fprot field descriptions field description 7 fpopen flash protection operation enable ?the fpopen bit determines the protection function for program or erase operations as shown in table 24-18 for the p-flash block. 0 when fpopen is clear, the fphdis bit de?es an unprotected address range as speci?d by the fphs bits 1 when fpopen is set, the fphdis bit enables protection for the address range speci?d by the fphs bits 6 rnv[6] reserved nonvolatile bit ?the rnv bit should remain in the erased state for future enhancements. 5 fphdis flash protection higher address range disable ?the fphdis bit determines whether there is a protected/unprotected area in a speci? region of the p-flash memory ending with global address 0x3_ffff. 0 protection/unprotection enabled 1 protection/unprotection disabled 4? fphs[1:0] flash protection higher address size the fphs bits determine the size of the protected/unprotected area in p-flash memory as shown in table 24-19 . the fphs bits can only be written to while the fphdis bit is set. 2? rnv[2:0] reserved nonvolatile bits ?these rnv bits should remain in the erased state. table 24-18. p-flash protection function fpopen fphdis function 1 1 for range sizes, refer to table 24-19 . 1 1 no p-flash protection 1 0 protected high range 0 1 full p-flash memory protected 0 0 unprotected high range table 24-19. p-flash protection higher address range fphs[1:0] global address range protected size 00 0x3_f800?x3_ffff 2 kbytes 01 0x3_f000?x3_ffff 4 kbytes 10 0x3_e000?x3_ffff 8 kbytes 11 0x3_c000?x3_ffff 16 kbytes
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 797 24.3.2.10 eeprom protection register (eeprot) the eeprot register de?es which eeprom sectors are protected against program and erase operations. the (unreserved) bits of the eeprot register are writable with the restriction that protection can be added but not removed. writes must increase the dps value and the dpopen bit can only be written from 1 (protection disabled) to 0 (protection enabled). if the dpopen bit is set, the state of the dps bits is irrelevant. during the reset sequence, ?lds dpopen and dps of the eeprot register are loaded with the contents of the eeprom protection byte in the flash configuration field at global address 0x3_ff0d located in p-flash memory (see table 24-4 ) as indicated by reset condition f in table 24-21 . to change the eeprom protection that will be loaded during the reset sequence, the p-flash sector containing the eeprom protection byte must be unprotected, then the eeprom protection byte must be programmed. if a double bit fault is detected while reading the p-flash phrase containing the eeprom protection byte during the reset sequence, the dpopen bit will be cleared and dps bits will be set to leave the eeprom memory fully protected. trying to alter data in any protected area in the eeprom memory will result in a protection violation error and the fpviol bit will be set in the fstat register. block erase of the eeprom memory is not possible if any of the eeprom sectors are protected. offset module base + 0x0009 76543210 r dpopen 00 dps[4:0] w reset f 1 1 loaded from ifr flash con?uration ?ld, during reset sequence. 00f 1 f 1 f 1 f 1 f 1 = unimplemented or reserved figure 24-14. eeprom protection register (eeprot) table 24-20. eeprot field descriptions field description 7 dpopen eeprom protection control 0 enables eeprom memory protection from program and erase with protected address range de?ed by dps bits 1 disables eeprom memory protection from program and erase 4? dps[4:0] eeprom protection size ?the dps[4:0] bits determine the size of the protected area in the eeprom memory as shown in table 24-21 .
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 798 freescale semiconductor 24.3.2.11 flash common command object register (fccob) the fccob is an array of six words addressed via the ccobix index found in the fccobix register. byte wide reads and writes are allowed to the fccob register. 24.3.2.11.1 fccob - nvm command mode nvm command mode uses the indexed fccob register to provide a command code and its relevant parameters to the memory controller. the user ?st sets up all required fccob ?lds and then initiates table 24-21. eeprom protection address range dps[4:0] global address range protected size 00000 0x0_0400 ?0x0_041f 32 bytes 00001 0x0_0400 ?0x0_043f 64 bytes 00010 0x0_0400 ?0x0_045f 96 bytes 00011 0x0_0400 ?0x0_047f 128 bytes 00100 0x0_0400 ?0x0_049f 160 bytes 00101 0x0_0400 ?0x0_04bf 192 bytes the protection size goes on enlarging in step of 32 bytes, for each dps value increasing of one. . . . 01111 - to - 11111 0x0_0400 ?0x0_05ff 512 bytes offset module base + 0x000a 76543210 r ccob[15:8] w reset 00000000 figure 24-15. flash common command object high register (fccobhi) offset module base + 0x000b 76543210 r ccob[7:0] w reset 00000000 figure 24-16. flash common command object low register (fccoblo)
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 799 the commands execution by writing a 1 to the ccif bit in the fstat register (a 1 written by the user clears the ccif command completion ?g to 0). when the user clears the ccif bit in the fstat register all fccob parameter ?lds are locked and cannot be changed by the user until the command completes (as evidenced by the memory controller returning ccif to 1). some commands return information to the fccob register array. the generic format for the fccob parameter ?lds in nvm command mode is shown in table 24-22 . the return values are available for reading after the ccif ?g in the fstat register has been returned to 1 by the memory controller. writes to the unimplemented parameter ?lds (ccobix = 110 and ccobix = 111) are ignored with reads from these ?lds returning 0x0000. table 24-22 shows the generic flash command format. the high byte of the ?st word in the ccob array contains the command code, followed by the parameters for this speci? flash command. for details on the fccob settings required by each command, see the flash command descriptions in section 24.4.6 . 24.3.2.12 flash reserved1 register (frsv1) this flash register is reserved for factory testing. all bits in the frsv1 register read 0 and are not writable. table 24-22. fccob - nvm command mode (typical usage) ccobix[2:0] byte fccob parameter fields (nvm command mode) 000 hi fcmd[7:0] de?ing flash command lo 6?0, global address [17:16] 001 hi global address [15:8] lo global address [7:0] 010 hi data 0 [15:8] lo data 0 [7:0] 011 hi data 1 [15:8] lo data 1 [7:0] 100 hi data 2 [15:8] lo data 2 [7:0] 101 hi data 3 [15:8] lo data 3 [7:0] offset module base + 0x000c 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 24-17. flash reserved1 register (frsv1)
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 800 freescale semiconductor 24.3.2.13 flash reserved2 register (frsv2) this flash register is reserved for factory testing. all bits in the frsv2 register read 0 and are not writable. 24.3.2.14 flash reserved3 register (frsv3) this flash register is reserved for factory testing. all bits in the frsv3 register read 0 and are not writable. 24.3.2.15 flash reserved4 register (frsv4) this flash register is reserved for factory testing. all bits in the frsv4 register read 0 and are not writable. offset module base + 0x000d 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 24-18. flash reserved2 register (frsv2) offset module base + 0x000e 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 24-19. flash reserved3 register (frsv3) offset module base + 0x000f 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 24-20. flash reserved4 register (frsv4)
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 801 24.3.2.16 flash option register (fopt) the fopt register is the flash option register. all bits in the fopt register are readable but are not writable. during the reset sequence, the fopt register is loaded from the flash nonvolatile byte in the flash con?uration ?ld at global address 0x3_ff0e located in p-flash memory (see table 24-4 ) as indicated by reset condition f in figure 24-21 . if a double bit fault is detected while reading the p-flash phrase containing the flash nonvolatile byte during the reset sequence, all bits in the fopt register will be set. 24.3.2.17 flash reserved5 register (frsv5) this flash register is reserved for factory testing. all bits in the frsv5 register read 0 and are not writable. 24.3.2.18 flash reserved6 register (frsv6) this flash register is reserved for factory testing. offset module base + 0x0010 76543210 r nv[7:0] w reset f 1 1 loaded from ifr flash con?uration ?ld, during reset sequence. f 1 f 1 f 1 f 1 f 1 f 1 f 1 = unimplemented or reserved figure 24-21. flash option register (fopt) table 24-23. fopt field descriptions field description 7? nv[7:0] nonvolatile bits the nv[7:0] bits are available as nonvolatile bits. refer to the device user guide for proper use of the nv bits. offset module base + 0x0011 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 24-22. flash reserved5 register (frsv5)
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 802 freescale semiconductor all bits in the frsv6 register read 0 and are not writable. 24.3.2.19 flash reserved7 register (frsv7) this flash register is reserved for factory testing. all bits in the frsv7 register read 0 and are not writable. offset module base + 0x0012 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 24-23. flash reserved6 register (frsv6) offset module base + 0x0013 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 24-24. flash reserved7 register (frsv7)
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 803 24.4 functional description 24.4.1 modes of operation the ftmrg16k1 module provides the modes of operation normal and special . the operating mode is determined by module-level inputs and affects the fclkdiv, fcnfg, and eeprot registers (see table 24-25 ). 24.4.2 ifr version id word the version id word is stored in the ifr at address 0x0_40b6. the contents of the word are de?ed in table 24-24 . vernum: version number. the ?st version is number 0b_0001 with both 0b_0000 and 0b_1111 meaning ?one? 24.4.3 internal nvm resource (nvmres) ifr is an internal nvm resource readable by cpu , when nvmres is active. the ifr ?lds are shown in table 24-5 . the nvmres global address map is shown in table 24-6 . 24.4.4 flash command operations flash command operations are used to modify flash memory contents. the next sections describe: how to write the fclkdiv register that is used to generate a time base (fclk) derived from busclk for flash program and erase command operations the command write sequence used to set flash command parameters and launch execution valid flash commands available for execution, according to mcu functional mode and mcu security state. 24.4.4.1 writing the fclkdiv register prior to issuing any flash program or erase command after a reset, the user is required to write the fclkdiv register to divide busclk down to a target fclk of 1 mhz. table 24-8 shows recommended values for the fdiv ?ld based on busclk frequency. table 24-24. ifr version id fields [15:4] [3:0] reserved vernum
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 804 freescale semiconductor note programming or erasing the flash memory cannot be performed if the bus clock runs at less than 0.8 mhz. setting fdiv too high can destroy the flash memory due to overstress. setting fdiv too low can result in incomplete programming or erasure of the flash memory cells. when the fclkdiv register is written, the fdivld bit is set automatically. if the fdivld bit is 0, the fclkdiv register has not been written since the last reset. if the fclkdiv register has not been written, any flash program or erase command loaded during a command write sequence will not execute and the accerr bit in the fstat register will set. 24.4.4.2 command write sequence the memory controller will launch all valid flash commands entered using a command write sequence. before launching a command, the accerr and fpviol bits in the fstat register must be clear (see section 24.3.2.7 ) and the ccif ?g should be tested to determine the status of the current command write sequence. if ccif is 0, the previous command write sequence is still active, a new command write sequence cannot be started, and all writes to the fccob register are ignored. 24.4.4.2.1 de?e fccob contents the fccob parameter ?lds must be loaded with all required parameters for the flash command being executed. access to the fccob parameter ?lds is controlled via the ccobix bits in the fccobix register (see section 24.3.2.3 ). the contents of the fccob parameter ?lds are transferred to the memory controller when the user clears the ccif command completion ?g in the fstat register (writing 1 clears the ccif to 0). the ccif ?g will remain clear until the flash command has completed. upon completion, the memory controller will return ccif to 1 and the fccob register will be used to communicate any results. the ?w for a generic command write sequence is shown in figure 24-25 .
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 805 figure 24-25. generic flash command write sequence flowchart write to fccobix register write: fstat register (to launch command) clear ccif 0x80 clear accerr/fpviol 0x30 write: fstat register yes no access error and protection violation read: fstat register start check fccob accerr/ fpviol set? exit write: fclkdiv register read: fclkdiv register yes no fdiv correct? no bit polling for command completion check yes ccif set? to identify speci? command parameter to load. write to fccob register to load required command parameter. yes no more parameters? availability check results from previous command note: fclkdiv must be set after each reset read: fstat register no yes ccif set? no yes ccif set? clock divider value check read: fstat register
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 806 freescale semiconductor 24.4.4.3 valid flash module commands table 24-25 present the valid flash commands, as enabled by the combination of the functional mcu mode (normal singlechip ns, special singlechip ss) with the mcu security state (unsecured, secured). special singlechip mode is selected by input mmc_ss_mode_ts2 asserted. mcu secured state is selected by input mmc_secure input asserted. + 24.4.4.4 p-flash commands table 24-26 summarizes the valid p-flash commands along with the effects of the commands on the p-flash block and other resources within the flash module. table 24-25. flash commands by mode and security state fcmd command unsecured secured ns 1 1 unsecured normal single chip mode ss 2 2 unsecured special single chip mode. ns 3 3 secured normal single chip mode. ss 4 4 secured special single chip mode. 0x01 erase verify all blocks ???? 0x02 erase verify block ???? 0x03 erase verify p-flash section ??? 0x04 read once ??? 0x06 program p-flash ??? 0x07 program once ??? 0x08 erase all blocks ?? 0x09 erase flash block ??? 0x0a erase p-flash sector ??? 0x0b unsecure flash ?? 0x0c verify backdoor access key ?? 0x0d set user margin level ??? 0x0e set field margin level ? 0x10 erase verify eeprom section ??? 0x11 program eeprom ??? 0x12 erase eeprom sector ??? table 24-26. p-flash commands fcmd command function on p-flash memory 0x01 erase verify all blocks verify that all p-flash (and eeprom) blocks are erased.
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 807 24.4.4.5 eeprom commands table 24-27 summarizes the valid eeprom commands along with the effects of the commands on the eeprom block. 0x02 erase verify block verify that a p-flash block is erased. 0x03 erase verify p-flash section verify that a given number of words starting at the address provided are erased. 0x04 read once read a dedicated 64 byte ?ld in the nonvolatile information register in p-flash block that was previously programmed using the program once command. 0x06 program p-flash program a phrase in a p-flash block. 0x07 program once program a dedicated 64 byte ?ld in the nonvolatile information register in p-flash block that is allowed to be programmed only once. 0x08 erase all blocks erase all p-flash (and eeprom) blocks. an erase of all flash blocks is only possible when the fpldis, fphdis, and fpopen bits in the fprot register and the dpopen bit in the eeprot register are set prior to launching the command. 0x09 erase flash block erase a p-flash (or eeprom) block. an erase of the full p-flash block is only possible when fpldis, fphdis and fpopen bits in the fprot register are set prior to launching the command. 0x0a erase p-flash sector erase all bytes in a p-flash sector. 0x0b unsecure flash supports a method of releasing mcu security by erasing all p-flash (and eeprom) blocks and verifying that all p-flash (and eeprom) blocks are erased. 0x0c verify backdoor access key supports a method of releasing mcu security by verifying a set of security keys. 0x0d set user margin level speci?s a user margin read level for all p-flash blocks. 0x0e set field margin level speci?s a ?ld margin read level for all p-flash blocks (special modes only). table 24-27. eeprom commands fcmd command function on eeprom memory 0x01 erase verify all blocks verify that all eeprom (and p-flash) blocks are erased. 0x02 erase verify block verify that the eeprom block is erased. table 24-26. p-flash commands fcmd command function on p-flash memory
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 808 freescale semiconductor 24.4.5 allowed simultaneous p-flash and eeprom operations only the operations marked ?k?in table 24-28 are permitted to be run simultaneously on the program flash and eeprom blocks. some operations cannot be executed simultaneously because certain hardware resources are shared by the two memories. the priority has been placed on permitting program flash reads while program and erase operations execute on the eeprom, providing read (p-flash) while write (eeprom) functionality. 0x08 erase all blocks erase all eeprom (and p-flash) blocks. an erase of all flash blocks is only possible when the fpldis, fphdis, and fpopen bits in the fprot register and the dpopen bit in the eeprot register are set prior to launching the command. 0x09 erase flash block erase a eeprom (or p-flash) block. an erase of the full eeprom block is only possible when dpopen bit in the eeprot register is set prior to launching the command. 0x0b unsecure flash supports a method of releasing mcu security by erasing all eeprom (and p-flash) blocks and verifying that all eeprom (and p-flash) blocks are erased. 0x0d set user margin level speci?s a user margin read level for the eeprom block. 0x0e set field margin level speci?s a ?ld margin read level for the eeprom block (special modes only). 0x10 erase verify eeprom section verify that a given number of words starting at the address provided are erased. 0x11 program eeprom program up to four words in the eeprom block. 0x12 erase eeprom sector erase all bytes in a sector of the eeprom block. table 24-28. allowed p-flash and eeprom simultaneous operations eeprom program flash read margin read 1 program sector erase mass erase 2 read ok ok ok margin read 1 1 a ?argin read?is any read after executing the margin setting commands ?et user margin level?or ?et field margin level?with anything but the ?ormal level speci?d. see the note on margin settings in section 24.4.6.12 and section 24.4.6.13 . program sector erase mass erase 2 2 the ?ass erase?operations are commands ?rase all blocks?and ?rase flash block ok table 24-27. eeprom commands fcmd command function on eeprom memory
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 809 24.4.6 flash command description this section provides details of all available flash commands launched by a command write sequence. the accerr bit in the fstat register will be set during the command write sequence if any of the following illegal steps are performed, causing the command not to be processed by the memory controller: starting any command write sequence that programs or erases flash memory before initializing the fclkdiv register writing an invalid command as part of the command write sequence for additional possible errors, refer to the error handling table provided for each command if a flash block is read during execution of an algorithm (ccif = 0) on that same block, the read operation will return invalid data if both ?gs sfdif and dfdif are set. if the sfdif or dfdif ?gs were not previously set when the invalid read operation occurred, both the sfdif and dfdif ?gs will be set. if the accerr or fpviol bits are set in the fstat register, the user must clear these bits before starting any command write sequence (see section 24.3.2.7 ). caution a flash word or phrase must be in the erased state before being programmed. cumulative programming of bits within a flash word or phrase is not allowed. 24.4.6.1 erase verify all blocks command the erase verify all blocks command will verify that all p-flash and eeprom blocks have been erased. upon clearing ccif to launch the erase verify all blocks command, the memory controller will verify that the entire flash memory space is erased. the ccif ?g will set after the erase verify all blocks operation has completed. if all blocks are not erased, it means blank check failed, both mgstat bits will be set. table 24-29. erase verify all blocks command fccob requirements ccobix[2:0] fccob parameters 000 0x01 not required table 24-30. erase verify all blocks command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 000 at command launch fpviol none mgstat1 set if any errors have been encountered during the read 1 or if blank check failed . 1 as found in the memory map for ftmrg32k1. mgstat0 set if any non-correctable errors have been encountered during the read or if blank check failed.
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 810 freescale semiconductor 24.4.6.2 erase verify block command the erase verify block command allows the user to verify that an entire p-flash or eeprom block has been erased. the fccob flashblockselectioncode[1:0] bits determine which block must be veri?d. upon clearing ccif to launch the erase verify block command, the memory controller will verify that the selected p-flash or eeprom block is erased. the ccif ?g will set after the erase verify block operation has completed.if the block is not erased, it means blank check failed, both mgstat bits will be set. 24.4.6.3 erase verify p-flash section command the erase verify p-flash section command will verify that a section of code in the p-flash memory is erased. the erase verify p-flash section command de?es the starting point of the code to be veri?d and the number of phrases. table 24-31. erase verify block command fccob requirements ccobix[2:0] fccob parameters 000 0x02 flash block selection code [1:0] . see table 24-32 table 24-32. flash block selection code description selection code[1:0] flash block to be veri?d 00 eeprom 01 invalid (accerr) 10 invalid (accerr) 11 p-flash table 24-33. erase verify block command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 000 at command launch set if an invalid flashblockselectioncode[1:0] is supplied 1 1 as de?ed by the memory map for ftmrg32k1. fpviol none mgstat1 set if any errors have been encountered during the read 2 or if blank check failed. 2 as found in the memory map for ftmrg32k1. mgstat0 set if any non-correctable errors have been encountered during the read 2 or if blank check failed.
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 811 upon clearing ccif to launch the erase verify p-flash section command, the memory controller will verify the selected section of flash memory is erased. the ccif ?g will set after the erase verify p-flash section operation has completed. if the section is not erased, it means blank check failed, both mgstat bits will be set. 24.4.6.4 read once command the read once command provides read access to a reserved 64 byte ?ld (8 phrases) located in the nonvolatile information register of p-flash. the read once ?ld is programmed using the program once command described in section 24.4.6.6 . the read once command must not be executed from the flash block containing the program once reserved ?ld to avoid code runaway. table 24-34. erase verify p-flash section command fccob requirements ccobix[2:0] fccob parameters 000 0x03 global address [17:16] of a p-flash block 001 global address [15:0] of the ?st phrase to be veri?d 010 number of phrases to be veri?d table 24-35. erase verify p-flash section command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 010 at command launch set if command not available in current mode (see table 24-25 ) set if an invalid global address [17:0] is supplied see table 24-3 ) 1 1 as de?ed by the memory map for ftmrg32k1. set if a misaligned phrase address is supplied (global address [2:0] != 000) set if the requested section crosses a the p-flash address boundary fpviol none mgstat1 set if any errors have been encountered during the read 2 or if blank check failed. 2 as found in the memory map for ftmrg32k1. mgstat0 set if any non-correctable errors have been encountered during the read 2 or if blank check failed. table 24-36. read once command fccob requirements ccobix[2:0] fccob parameters 000 0x04 not required 001 read once phrase index (0x0000 - 0x0007) 010 read once word 0 value 011 read once word 1 value 100 read once word 2 value
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 812 freescale semiconductor upon clearing ccif to launch the read once command, a read once phrase is fetched and stored in the fccob indexed register. the ccif ?g will set after the read once operation has completed. valid phrase index values for the read once command range from 0x0000 to 0x0007. during execution of the read once command, any attempt to read addresses within p-flash block will return invalid data. 8 24.4.6.5 program p-flash command the program p-flash operation will program a previously erased phrase in the p-flash memory using an embedded algorithm. caution a p-flash phrase must be in the erased state before being programmed. cumulative programming of bits within a flash phrase is not allowed. upon clearing ccif to launch the program p-flash command, the memory controller will program the data words to the supplied global address and will then proceed to verify the data words read back as expected. the ccif ?g will set after the program p-flash operation has completed. 101 read once word 3 value table 24-37. read once command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 24-25 ) set if an invalid phrase index is supplied fpviol none mgstat1 set if any errors have been encountered during the read mgstat0 set if any non-correctable errors have been encountered during the read table 24-38. program p-flash command fccob requirements ccobix[2:0] fccob parameters 000 0x06 global address [17:16] to identify p-flash block 001 global address [15:0] of phrase location to be programmed 1 1 global address [2:0] must be 000 010 word 0 program value 011 word 1 program value 100 word 2 program value 101 word 3 program value table 24-36. read once command fccob requirements ccobix[2:0] fccob parameters
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 813 24.4.6.6 program once command the program once command restricts programming to a reserved 64 byte ?ld (8 phrases) in the nonvolatile information register located in p-flash. the program once reserved ?ld can be read using the read once command as described in section 24.4.6.4 . the program once command must only be issued once since the nonvolatile information register in p-flash cannot be erased. the program once command must not be executed from the flash block containing the program once reserved ?ld to avoid code runaway. upon clearing ccif to launch the program once command, the memory controller ?st veri?s that the selected phrase is erased. if erased, then the selected phrase will be programmed and then veri?d with read back. the ccif ?g will remain clear, setting only after the program once operation has completed. the reserved nonvolatile information register accessed by the program once command cannot be erased and any attempt to program one of these phrases a second time will not be allowed. valid phrase index values for the program once command range from 0x0000 to 0x0007. during execution of the program once command, any attempt to read addresses within p-flash will return invalid data. table 24-39. program p-flash command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 101 at command launch set if command not available in current mode (see table 24-25 ) set if an invalid global address [17:0] is supplied see table 24-3 ) 1 1 as de?ed by the memory map for ftmrg32k1. set if a misaligned phrase address is supplied (global address [2:0] != 000) fpviol set if the global address [17:0] points to a protected area mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation table 24-40. program once command fccob requirements ccobix[2:0] fccob parameters 000 0x07 not required 001 program once phrase index (0x0000 - 0x0007) 010 program once word 0 value 011 program once word 1 value 100 program once word 2 value 101 program once word 3 value
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 814 freescale semiconductor 24.4.6.7 erase all blocks command the erase all blocks operation will erase the entire p-flash and eeprom memory space. upon clearing ccif to launch the erase all blocks command, the memory controller will erase the entire flash memory space and verify that it is erased. if the memory controller veri?s that the entire flash memory space was properly erased, security will be released. during the execution of this command (ccif=0) the user must not write to any flash module register. the ccif ?g will set after the erase all blocks operation has completed. 24.4.6.8 erase flash block command the erase flash block operation will erase all addresses in a p-flash or eeprom block. table 24-41. program once command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 101 at command launch set if command not available in current mode (see table 24-25 ) set if an invalid phrase index is supplied set if the requested phrase has already been programmed 1 1 if a program once phrase is initially programmed to 0xffff_ffff_ffff_ffff, the program once command will be allowed to execute again on that same phrase. fpviol none mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation table 24-42. erase all blocks command fccob requirements ccobix[2:0] fccob parameters 000 0x08 not required table 24-43. erase all blocks command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 000 at command launch set if command not available in current mode (see table 24-25 ) fpviol set if any area of the p-flash or eeprom memory is protected mgstat1 set if any errors have been encountered during the verify operation 1 1 as found in the memory map for ftmrg32k1. mgstat0 set if any non-correctable errors have been encountered during the verify operation 1
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 815 upon clearing ccif to launch the erase flash block command, the memory controller will erase the selected flash block and verify that it is erased. the ccif ?g will set after the erase flash block operation has completed. 24.4.6.9 erase p-flash sector command the erase p-flash sector operation will erase all addresses in a p-flash sector. upon clearing ccif to launch the erase p-flash sector command, the memory controller will erase the selected flash sector and then verify that it is erased. the ccif ?g will be set after the erase p-flash sector operation has completed. table 24-44. erase flash block command fccob requirements ccobix[2:0] fccob parameters 000 0x09 global address [17:16] to identify flash block 001 global address [15:0] in flash block to be erased table 24-45. erase flash block command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 24-25 ) set if an invalid global address [17:16] is supplied 1 1 as de?ed by the memory map for ftmrg32k1. set if the supplied p-flash address is not phrase-aligned or if the eeprom address is not word-aligned fpviol set if an area of the selected flash block is protected mgstat1 set if any errors have been encountered during the verify operation 2 2 as found in the memory map for ftmrg32k1. mgstat0 set if any non-correctable errors have been encountered during the verify operation 2 table 24-46. erase p-flash sector command fccob requirements ccobix[2:0] fccob parameters 000 0x0a global address [17:16] to identify p-flash block to be erased 001 global address [15:0] anywhere within the sector to be erased. refer to section 24.1.2.1 for the p-flash sector size.
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 816 freescale semiconductor 24.4.6.10 unsecure flash command the unsecure flash command will erase the entire p-flash and eeprom memory space and, if the erase is successful, will release security. upon clearing ccif to launch the unsecure flash command, the memory controller will erase the entire p-flash and eeprom memory space and verify that it is erased. if the memory controller veri?s that the entire flash memory space was properly erased, security will be released. if the erase verify is not successful, the unsecure flash operation sets mgstat1 and terminates without changing the security state. during the execution of this command (ccif=0) the user must not write to any flash module register. the ccif ?g is set after the unsecure flash operation has completed. table 24-47. erase p-flash sector command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 24-25 ) set if an invalid global address [17:16] is supplied see table 24-3 ) 1 1 as de?ed by the memory map for ftmrg32k1. set if a misaligned phrase address is supplied (global address [2:0] != 000) fpviol set if the selected p-flash sector is protected mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation table 24-48. unsecure flash command fccob requirements ccobix[2:0] fccob parameters 000 0x0b not required table 24-49. unsecure flash command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 000 at command launch set if command not available in current mode (see table 24-25 ) fpviol set if any area of the p-flash or eeprom memory is protected mgstat1 set if any errors have been encountered during the verify operation 1 1 as found in the memory map for ftmrg32k1. mgstat0 set if any non-correctable errors have been encountered during the verify operation 1
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 817 24.4.6.11 verify backdoor access key command the verify backdoor access key command will only execute if it is enabled by the keyen bits in the fsec register (see table 24-10 ). the verify backdoor access key command releases security if user-supplied keys match those stored in the flash security bytes of the flash con?uration ?ld (see table 24-4 ). the verify backdoor access key command must not be executed from the flash block containing the backdoor comparison key to avoid code runaway. upon clearing ccif to launch the verify backdoor access key command, the memory controller will check the fsec keyen bits to verify that this command is enabled. if not enabled, the memory controller sets the accerr bit in the fstat register and terminates. if the command is enabled, the memory controller compares the key provided in fccob to the backdoor comparison key in the flash con?uration ?ld with key 0 compared to 0x3_ff00, etc. if the backdoor keys match, security will be released. if the backdoor keys do not match, security is not released and all future attempts to execute the verify backdoor access key command are aborted (set accerr) until a reset occurs. the ccif flag is set after the verify backdoor access key operation has completed. 24.4.6.12 set user margin level command the set user margin level command causes the memory controller to set the margin level for future read operations of the p-flash or eeprom block. table 24-50. verify backdoor access key command fccob requirements ccobix[2:0] fccob parameters 000 0x0c not required 001 key 0 010 key 1 011 key 2 100 key 3 table 24-51. verify backdoor access key command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 100 at command launch set if an incorrect backdoor key is supplied set if backdoor key access has not been enabled (keyen[1:0] != 10, see section 24.3.2.2 ) set if the backdoor key has mismatched since the last reset fpviol none mgstat1 none mgstat0 none
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 818 freescale semiconductor upon clearing ccif to launch the set user margin level command, the memory controller will set the user margin level for the targeted block and then set the ccif ?g. note when the eeprom block is targeted, the eeprom user margin levels are applied only to the eeprom reads. however, when the p-flash block is targeted, the p-flash user margin levels are applied to both p-flash and eeprom reads. it is not possible to apply user margin levels to the p-flash block only. valid margin level settings for the set user margin level command are de?ed in table 24-53 . table 24-52. set user margin level command fccob requirements ccobix[2:0] fccob parameters 000 0x0d flash block selection code [1:0] . see table 24-32 001 margin level setting. table 24-53. valid set user margin level settings ccob (ccobix=001) level description 0x0000 return to normal level 0x0001 user margin-1 level 1 1 read margin to the erased state 0x0002 user margin-0 level 2 2 read margin to the programmed state table 24-54. set user margin level command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 24-25 ) set if an invalid flashblockselectioncode[1:0] is supplied (see table 24-32 ) set if an invalid margin level setting is supplied fpviol none mgstat1 none mgstat0 none
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 819 note user margin levels can be used to check that flash memory contents have adequate margin for normal level read operations. if unexpected results are encountered when checking flash memory contents at user margin levels, a potential loss of information has been detected. 24.4.6.13 set field margin level command the set field margin level command, valid in special modes only, causes the memory controller to set the margin level speci?d for future read operations of the p-flash or eeprom block. upon clearing ccif to launch the set field margin level command, the memory controller will set the ?ld margin level for the targeted block and then set the ccif ?g. note when the eeprom block is targeted, the eeprom ?ld margin levels are applied only to the eeprom reads. however, when the p-flash block is targeted, the p-flash ?ld margin levels are applied to both p-flash and eeprom reads. it is not possible to apply ?ld margin levels to the p-flash block only. valid margin level settings for the set field margin level command are de?ed in table 24-56 . table 24-55. set field margin level command fccob requirements ccobix[2:0] fccob parameters 000 0x0e flash block selection code [1:0] . see table 24-32 001 margin level setting. table 24-56. valid set field margin level settings ccob (ccobix=001) level description 0x0000 return to normal level 0x0001 user margin-1 level 1 1 read margin to the erased state 0x0002 user margin-0 level 2 2 read margin to the programmed state 0x0003 field margin-1 level 1 0x0004 field margin-0 level 2
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 820 freescale semiconductor caution field margin levels must only be used during verify of the initial factory programming. note field margin levels can be used to check that flash memory contents have adequate margin for data retention at the normal level setting. if unexpected results are encountered when checking flash memory contents at ?ld margin levels, the flash memory contents should be erased and reprogrammed. 24.4.6.14 erase verify eeprom section command the erase verify eeprom section command will verify that a section of code in the eeprom is erased. the erase verify eeprom section command de?es the starting point of the data to be veri?d and the number of words. upon clearing ccif to launch the erase verify eeprom section command, the memory controller will verify the selected section of eeprom memory is erased. the ccif ?g will set after the erase verify eeprom section operation has completed. if the section is not erased, it means blank check failed, both mgstat bits will be set. table 24-57. set field margin level command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 24-25 ) set if an invalid flashblockselectioncode[1:0] is supplied (see table 24-32 ) 1 1 as de?ed by the memory map for ftmrg32k1. set if an invalid margin level setting is supplied fpviol none mgstat1 none mgstat0 none table 24-58. erase verify eeprom section command fccob requirements ccobix[2:0] fccob parameters 000 0x10 global address [17:16] to identify the eeprom block 001 global address [15:0] of the ?st word to be veri?d 010 number of words to be veri?d
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 821 24.4.6.15 program eeprom command the program eeprom operation programs one to four previously erased words in the eeprom block. the program eeprom operation will con?m that the targeted location(s) were successfully programmed upon completion. caution a flash word must be in the erased state before being programmed. cumulative programming of bits within a flash word is not allowed. upon clearing ccif to launch the program eeprom command, the user-supplied words will be transferred to the memory controller and be programmed if the area is unprotected. the ccobix index value at program eeprom command launch determines how many words will be programmed in the eeprom block. the ccif ?g is set when the operation has completed. table 24-59. erase verify eeprom section command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 010 at command launch set if command not available in current mode (see table 24-25 ) set if an invalid global address [17:0] is supplied set if a misaligned word address is supplied (global address [0] != 0) set if the requested section breaches the end of the eeprom block fpviol none mgstat1 set if any errors have been encountered during the read or if blank check failed. mgstat0 set if any non-correctable errors have been encountered during the read or if blank check failed. table 24-60. program eeprom command fccob requirements ccobix[2:0] fccob parameters 000 0x11 global address [17:16] to identify the eeprom block 001 global address [15:0] of word to be programmed 010 word 0 program value 011 word 1 program value, if desired 100 word 2 program value, if desired 101 word 3 program value, if desired
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 822 freescale semiconductor 24.4.6.16 erase eeprom sector command the erase eeprom sector operation will erase all addresses in a sector of the eeprom block. upon clearing ccif to launch the erase eeprom sector command, the memory controller will erase the selected flash sector and verify that it is erased. the ccif ?g will set after the erase eeprom sector operation has completed. table 24-61. program eeprom command error handling register error bit error condition fstat accerr set if ccobix[2:0] < 010 at command launch set if ccobix[2:0] > 101 at command launch set if command not available in current mode (see table 24-25 ) set if an invalid global address [17:0] is supplied set if a misaligned word address is supplied (global address [0] != 0) set if the requested group of words breaches the end of the eeprom block fpviol set if the selected area of the eeprom memory is protected mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation table 24-62. erase eeprom sector command fccob requirements ccobix[2:0] fccob parameters 000 0x12 global address [17:16] to identify eeprom block 001 global address [15:0] anywhere within the sector to be erased. see section 24.1.2.2 for eeprom sector size. table 24-63. erase eeprom sector command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 24-25 ) set if an invalid global address [17:0] is suppliedsee table 24-3 ) set if a misaligned word address is supplied (global address [0] != 0) fpviol set if the selected area of the eeprom memory is protected mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 823 24.4.7 interrupts the flash module can generate an interrupt when a flash command operation has completed or when a flash command operation has detected an ecc fault. note vector addresses and their relative interrupt priority are determined at the mcu level. 24.4.7.1 description of flash interrupt operation the flash module uses the ccif ?g in combination with the ccie interrupt enable bit to generate the flash command interrupt request. the flash module uses the dfdif and sfdif ?gs in combination with the dfdie and sfdie interrupt enable bits to generate the flash error interrupt request. for a detailed description of the register bits involved, refer to section 24.3.2.5, ?lash configuration register (fcnfg) ? section 24.3.2.6, ?lash error configuration register (fercnfg) ? section 24.3.2.7, ?lash status register (fstat) ? and section 24.3.2.8, ?lash error status register (ferstat) ? the logic used for generating the flash module interrupts is shown in figure 24-26 . figure 24-26. flash module interrupts implementation table 24-64. flash interrupt sources interrupt source interrupt flag local enable global (ccr) mask flash command complete ccif (fstat register) ccie (fcnfg register) i bit ecc double bit fault on flash read dfdif (ferstat register) dfdie (fercnfg register) i bit ecc single bit fault on flash read sfdif (ferstat register) sfdie (fercnfg register) i bit flash error interrupt request ccif ccie dfdif dfdie sfdif sfdie flash command interrupt request
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 824 freescale semiconductor 24.4.8 wait mode the flash module is not affected if the mcu enters wait mode. the flash module can recover the mcu from wait via the ccif interrupt (see section 24.4.7, ?nterrupts ). 24.4.9 stop mode if a flash command is active (ccif = 0) when the mcu requests stop mode, the current flash operation will be completed before the mcu is allowed to enter stop mode. 24.5 security the flash module provides security information to the mcu. the flash security state is de?ed by the sec bits of the fsec register (see table 24-11 ). during reset, the flash module initializes the fsec register using data read from the security byte of the flash con?uration ?ld at global address 0x3_ff0f. the security state out of reset can be permanently changed by programming the security byte assuming that the mcu is starting from a mode where the necessary p-flash erase and program commands are available and that the upper region of the p-flash is unprotected. if the flash security byte is successfully programmed, its new value will take affect after the next mcu reset. the following subsections describe these security-related subjects: unsecuring the mcu using backdoor key access unsecuring the mcu in special single chip mode using bdm mode and security effects on flash command availability 24.5.1 unsecuring the mcu using backdoor key access the mcu may be unsecured by using the backdoor key access feature which requires knowledge of the contents of the backdoor keys (four 16-bit words programmed at addresses 0x3_ff00-0x3_ff07). if the keyen[1:0] bits are in the enabled state (see section 24.3.2.2 ), the verify backdoor access key command (see section 24.4.6.11 ) allows the user to present four prospective keys for comparison to the keys stored in the flash memory via the memory controller. if the keys presented in the verify backdoor access key command match the backdoor keys stored in the flash memory, the sec bits in the fsec register (see table 24-11 ) will be changed to unsecure the mcu. key values of 0x0000 and 0xffff are not permitted as backdoor keys. while the verify backdoor access key command is active, p-flash memory and eeprom memory will not be available for read access and will return invalid data.
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 825 the user code stored in the p-flash memory must have a method of receiving the backdoor keys from an external stimulus. this external stimulus would typically be through one of the on-chip serial ports. if the keyen[1:0] bits are in the enabled state (see section 24.3.2.2 ), the mcu can be unsecured by the backdoor key access sequence described below: 1. follow the command sequence for the verify backdoor access key command as explained in section 24.4.6.11 2. if the verify backdoor access key command is successful, the mcu is unsecured and the sec[1:0] bits in the fsec register are forced to the unsecure state of 10 the verify backdoor access key command is monitored by the memory controller and an illegal key will prohibit future use of the verify backdoor access key command. a reset of the mcu is the only method to re-enable the verify backdoor access key command. the security as de?ed in the flash security byte (0x3_ff0f) is not changed by using the verify backdoor access key command sequence. the backdoor keys stored in addresses 0x3_ff00-0x3_ff07 are unaffected by the verify backdoor access key command sequence. the verify backdoor access key command sequence has no effect on the program and erase protections de?ed in the flash protection register, fprot. after the backdoor keys have been correctly matched, the mcu will be unsecured. after the mcu is unsecured, the sector containing the flash security byte can be erased and the flash security byte can be reprogrammed to the unsecure state, if desired. in the unsecure state, the user has full control of the contents of the backdoor keys by programming addresses 0x3_ff00-0x3_ff07 in the flash con?uration ?ld. 24.5.2 unsecuring the mcu in special single chip mode using bdm a secured mcu can be unsecured in special single chip mode by using the following method to erase the p-flash and eeprom memory: 1. reset the mcu into special single chip mode 2. delay while the bdm executes the erase verify all blocks command write sequence to check if the p-flash and eeprom memories are erased 3. send bdm commands to disable protection in the p-flash and eeprom memory 4. execute the erase all blocks command write sequence to erase the p-flash and eeprom memory. alternatively the unsecure flash command can be executed, if so the steps 5 and 6 below are skeeped. 5. after the ccif ?g sets to indicate that the erase all blocks operation has completed, reset the mcu into special single chip mode 6. delay while the bdm executes the erase verify all blocks command write sequence to verify that the p-flash and eeprom memory are erased if the p-flash and eeprom memory are veri?d as erased, the mcu will be unsecured. all bdm commands will now be enabled and the flash security byte may be programmed to the unsecure state by continuing with the following steps: 7. send bdm commands to execute the program p-flash command write sequence to program the flash security byte to the unsecured state
16 kbyte flash module (s12ftmrg16k1v1) mc9s12g family reference manual, rev.1.23 826 freescale semiconductor 8. reset the mcu 24.5.3 mode and security effects on flash command availability the availability of flash module commands depends on the mcu operating mode and security state as shown in table 24-25 . 24.6 initialization on each system reset the ?sh module executes an initialization sequence which establishes initial values for the flash block con?uration parameters, the fprot and eeprot protection registers, and the fopt and fsec registers. the initialization routine reverts to built-in default values that leave the module in a fully protected and secured state if errors are encountered during execution of the reset sequence. if a double bit fault is detected during the reset sequence, both mgstat bits in the fstat register will be set. ccif is cleared throughout the initialization sequence. the flash module holds off all cpu access for a portion of the initialization sequence. flash reads are allowed once the hold is removed. completion of the initialization sequence is marked by setting ccif high which enables user commands. if a reset occurs while any flash command is in progress, that command will be immediately aborted. the state of the word being programmed or the sector/block being erased is not guaranteed.
mc9s12g family reference manual, rev.1.23 freescale semiconductor 827 chapter 25 32 kbyte flash module (s12ftmrg32k1v1) 25.1 introduction the ftmrg32k1 module implements the following: 32kbytes of p-flash (program flash) memory 1 kbytes of eeprom memory the flash memory is ideal for single-supply applications allowing for ?ld reprogramming without requiring external high voltage sources for program or erase operations. the flash module includes a memory controller that executes commands to modify flash memory contents. the user interface to the memory controller consists of the indexed flash common command object (fccob) register which is written to with the command, global address, data, and any required command parameters. the memory controller must complete the execution of a command before the fccob register can be written to with a new command. caution a flash word or phrase must be in the erased state before being programmed. cumulative programming of bits within a flash word or phrase is not allowed. table 25-1. revision history revision number revision date sections affected description of changes v01.04 17 jun 2010 25.4.6.1/25-860 25.4.6.2/25-861 25.4.6.3/25-861 25.4.6.14/25-87 1 clarify erase verify commands descriptions related to the bits mgstat[1:0] of the register fstat. v01.05 20 aug 2010 25.4.6.2/25-861 25.4.6.12/25-86 8 25.4.6.13/25-87 0 updated description of the commands rd1blk, mloadu and mloadf rev.1.23 31 jan 2011 25.3.2.9/25-843 updated description of protection on section 25.3.2.9
mc9s12g family reference manual, rev.1.23 freescale semiconductor 828 the flash memory may be read as bytes and aligned words. read access time is one bus cycle for bytes and aligned words. for misaligned words access, the cpu has to perform twice the byte read access command. for flash memory, an erased bit reads 1 and a programmed bit reads 0. it is possible to read from p-flash memory while some commands are executing on eeprom memory. it is not possible to read from eeprom memory while a command is executing on p-flash memory. simultaneous p-flash and eeprom operations are discussed in section 25.4.5 . both p-flash and eeprom memories are implemented with error correction codes (ecc) that can resolve single bit faults and detect double bit faults. for p-flash memory, the ecc implementation requires that programming be done on an aligned 8 byte basis (a flash phrase). since p-flash memory is always read by half-phrase, only one single bit fault in an aligned 4 byte half-phrase containing the byte or word accessed will be corrected. 25.1.1 glossary command write sequence ?an mcu instruction sequence to execute built-in algorithms (including program and erase) on the flash memory. eeprom memory ?the eeprom memory constitutes the nonvolatile memory store for data. eeprom sector ?the eeprom sector is the smallest portion of the eeprom memory that can be erased. the eeprom sector consists of 4 bytes. nvm command mode an nvm mode using the cpu to setup the fccob register to pass parameters required for flash command execution. phrase ?an aligned group of four 16-bit words within the p-flash memory. each phrase includes two sets of aligned double words with each set including 7 ecc bits for single bit fault correction and double bit fault detection within each double word. p-flash memory the p-flash memory constitutes the main nonvolatile memory store for applications. p-flash sector ?the p-flash sector is the smallest portion of the p-flash memory that can be erased. each p-flash sector contains 512 bytes. program ifr ?nonvolatile information register located in the p-flash block that contains the version id, and the program once ?ld. 25.1.2 features 25.1.2.1 p-flash features 32 kbytes of p-flash memory composed of one 32 kbyte flash block divided into 64 sectors of 512 bytes
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 829 single bit fault correction and double bit fault detection within a 32-bit double word during read operations automated program and erase algorithm with verify and generation of ecc parity bits fast sector erase and phrase program operation ability to read the p-flash memory while programming a word in the eeprom memory flexible protection scheme to prevent accidental program or erase of p-flash memory 25.1.2.2 eeprom features 1 kbyte of eeprom memory composed of one 1 kbyte flash block divided into 256 sectors of 4 bytes single bit fault correction and double bit fault detection within a word during read operations automated program and erase algorithm with verify and generation of ecc parity bits fast sector erase and word program operation protection scheme to prevent accidental program or erase of eeprom memory ability to program up to four words in a burst sequence 25.1.2.3 other flash module features no external high-voltage power supply required for flash memory program and erase operations interrupt generation on flash command completion and flash error detection security mechanism to prevent unauthorized access to the flash memory 25.1.3 block diagram the block diagram of the flash module is shown in figure 25-1 .
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 830 freescale semiconductor figure 25-1. ftmrg32k1 block diagram 25.2 external signal description the flash module contains no signals that connect off-chip. bus clock divider clock command interrupt request fclk protection security registers flash interface 16bit internal bus sector 0 sector 1 sector 63 8kx39 p-flash error interrupt request cpu 512x22 sector 0 sector 1 sector 255 eeprom memory controller
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 831 25.3 memory map and registers this section describes the memory map and registers for the flash module. read data from unimplemented memory space in the flash module is unde?ed. write access to unimplemented or reserved memory space in the flash module will be ignored by the flash module. caution writing to the flash registers while a flash command is executing (that is indicated when the value of ?g ccif reads as ?? is not allowed. if such action is attempted the write operation will not change the register value. writing to the flash registers is allowed when the flash is not busy executing commands (ccif = 1) and during initialization right after reset, despite the value of ?g ccif in that case (refer to section 25.6 for a complete description of the reset sequence). . 25.3.1 module memory map the s12 architecture places the p-flash memory between global addresses 0x3_8000 and 0x3_ffff as shown in table 25-3 .the p-flash memory map is shown in figure 25-2 . table 25-2. ftmrg memory map global address (in bytes) size (bytes) description 0x0_0000 - 0x0_03ff 1,024 register space 0x0_0400 ?0x0_07ff 1,024 eeprom memory 0x0_4000 ?0x0_7fff 16,284 nvmres 1 =1 : nvm resource area (see figure 25-3 ) 1 see nvmres description in section 25.4.3 0x3_8000 ?0x3_ffff 32,768 p-flash memory table 25-3. p-flash memory addressing global address size (bytes) description 0x3_8000 ?0x3_ffff 32 k p-flash block contains flash con?uration field (see table 25-4 )
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 832 freescale semiconductor the fprot register, described in section 25.3.2.9 , can be set to protect regions in the flash memory from accidental program or erase. three separate memory regions, one growing upward from global address 0x3_8000 in the flash memory (called the lower region), one growing downward from global address 0x3_ffff in the flash memory (called the higher region), and the remaining addresses in the flash memory, can be activated for protection. the flash memory addresses covered by these protectable regions are shown in the p-flash memory map. the higher address region is mainly targeted to hold the boot loader code since it covers the vector space. default protection settings as well as security information that allows the mcu to restrict access to the flash module are stored in the flash con?uration ?ld as described in table 25-4 . table 25-4. flash con?uration field global address size (bytes) description 0x3_ff00-0x3_ff07 8 backdoor comparison key refer to section 25.4.6.11, ?erify backdoor access key command , and section 25.5.1, ?nsecuring the mcu using backdoor key access 0x3_ff08-0x3_ff0b 1 1 0x3ff08-0x3_ff0f form a flash phrase and must be programmed in a single command write sequence. each byte in the 0x3_ff08 - 0x3_ff0b reserved ?ld should be programmed to 0xff. 4 reserved 0x3_ff0c 1 1 p-flash protection byte . refer to section 25.3.2.9, ?-flash protection register (fprot) 0x3_ff0d 1 1 eeprom protection byte . refer to section 25.3.2.10, ?eprom protection register (eeprot) 0x3_ff0e 1 1 flash nonvolatile byte refer to section 25.3.2.16, ?lash option register (fopt) 0x3_ff0f 1 1 flash security byte refer to section 25.3.2.2, ?lash security register (fsec)
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 833 figure 25-2. p-flash memory map table 25-5. program ifr fields global address size (bytes) field description 0x0_4000 ?0x0_4007 8 reserved 0x0_4008 ?0x0_40b5 174 reserved 0x0_40b6 ?0x0_40b7 2 version id 1 1 used to track ?mware patch versions, see section 25.4.2 0x0_40b8 ?0x0_40bf 8 reserved 0x0_40c0 ?0x0_40ff 64 program once field refer to section 25.4.6.6, ?rogram once command flash con?uration field 0x3_c000 flash protected/unprotected lower region 1, 2, 4, 8 kbytes p-flash start = 0x3_8000 0x3_9000 0x3_8400 0x3_8800 0x3_a000 p-flash end = 0x3_ffff 0x3_f800 0x3_f000 0x3_e000 flash protected/unprotected higher region 2, 4, 8, 16 kbytes flash protected/unprotected region 8 kbytes (up to 29 kbytes) 16 bytes (0x3_ff00 - 0x3_ff0f) protection protection protection movable end fixed end fixed end
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 834 freescale semiconductor figure 25-3. memory controller resource memory map (nvmres=1) 25.3.2 register descriptions the flash module contains a set of 20 control and status registers located between flash module base + 0x0000 and 0x0013. in the case of the writable registers, the write accesses are forbidden during fash command execution (for more detail, see caution note in section 25.3 ). table 25-6. memory controller resource fields (nvmres 1 =1) 1 nvmres - see section 25.4.3 for nvmres (nvm resource) detail. global address size (bytes) description 0x0_4000 ?0x040ff 256 p-flash ifr (see table 25-5 ) 0x0_4100 ?0x0_41ff 256 reserved. 0x0_4200 ?0x0_57ff reserved 0x0_5800 ?0x0_59ff 512 reserved 0x0_5a00 ?0x0_5fff 1,536 reserved 0x0_6000 ?0x0_6bff 3,072 reserved 0x0_6c00 ?0x0_7fff 5,120 reserved p-flash ifr 1 kbyte (nvmres=1) 0x0_4000 ram end = 0x0_59ff ram start = 0x0_5800 reserved 5120 bytes reserved 4608 bytes 0x0_6c00 0x0_7fff 0x0_4400 reserved 5k bytes reserved 512 bytes
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 835 a summary of the flash module registers is given in figure 25-4 with detailed descriptions in the following subsections. address & name 76543210 0x0000 fclkdiv r fdivld fdivlck fdiv5 fdiv4 fdiv3 fdiv2 fdiv1 fdiv0 w 0x0001 fsec r keyen1 keyen0 rnv5 rnv4 rnv3 rnv2 sec1 sec0 w 0x0002 fccobix r0 0 0 0 0 ccobix2 ccobix1 ccobix0 w 0x0003 frsv0 r00000000 w 0x0004 fcnfg r ccie 00 ignsf 00 fdfd fsfd w 0x0005 fercnfg r0 0 0 0 0 0 dfdie sfdie w 0x0006 fstat r ccif 0 accerr fpviol mgbusy rsvd mgstat1 mgstat0 w 0x0007 ferstat r0 0 0 0 0 0 dfdif sfdif w 0x0008 fprot r fpopen rnv6 fphdis fphs1 fphs0 fpldis fpls1 fpls0 w 0x0009 eeprot r dpopen 00 dps4 dps3 dps2 dps1 dps0 w 0x000a fccobhi r ccob15 ccob14 ccob13 ccob12 ccob11 ccob10 ccob9 ccob8 w 0x000b fccoblo r ccob7 ccob6 ccob5 ccob4 ccob3 ccob2 ccob1 ccob0 w 0x000c frsv1 r00000000 w figure 25-4. ftmrg32k1 register summary
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 836 freescale semiconductor 25.3.2.1 flash clock divider register (fclkdiv) the fclkdiv register is used to control timed events in program and erase algorithms. all bits in the fclkdiv register are readable, bit 7 is not writable, bit 6 is write-once-hi and controls the writability of the fdiv ?ld in normal mode. in special mode, bits 6-0 are writable any number of times but bit 7 remains unwritable. 0x000d frsv2 r00000000 w 0x000e frsv3 r00000000 w 0x000f frsv4 r00000000 w 0x0010 fopt r nv7 nv6 nv5 nv4 nv3 nv2 nv1 nv0 w 0x0011 frsv5 r00000000 w 0x0012 frsv6 r00000000 w 0x0013 frsv7 r00000000 w = unimplemented or reserved offset module base + 0x0000 76543210 r fdivld fdivlck fdiv[5:0] w reset 00000000 = unimplemented or reserved figure 25-5. flash clock divider register (fclkdiv) address & name 76543210 figure 25-4. ftmrg32k1 register summary (continued)
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 837 caution the fclkdiv register should never be written while a flash command is executing (ccif=0). table 25-7. fclkdiv field descriptions field description 7 fdivld clock divider loaded 0 fclkdiv register has not been written since the last reset 1 fclkdiv register has been written since the last reset 6 fdivlck clock divider locked 0 fdiv ?ld is open for writing 1 fdiv value is locked and cannot be changed. once the lock bit is set high, only reset can clear this bit and restore writability to the fdiv ?ld in normal mode. 5? fdiv[5:0] clock divider bits fdiv[5:0] must be set to effectively divide busclk down to 1 mhz to control timed events during flash program and erase algorithms. table 25-8 shows recommended values for fdiv[5:0] based on the busclk frequency. please refer to section 25.4.4, ?lash command operations , for more information. table 25-8. fdiv values for various busclk frequencies busclk frequency (mhz) fdiv[5:0] busclk frequency (mhz) fdiv[5:0] min 1 1 busclk is greater than this value. max 2 2 busclk is less than or equal to this value. min 1 max 2 1.0 1.6 0x00 16.6 17.6 0x10 1.6 2.6 0x01 17.6 18.6 0x11 2.6 3.6 0x02 18.6 19.6 0x12 3.6 4.6 0x03 19.6 20.6 0x13 4.6 5.6 0x04 20.6 21.6 0x14 5.6 6.6 0x05 21.6 22.6 0x15 6.6 7.6 0x06 22.6 23.6 0x16 7.6 8.6 0x07 23.6 24.6 0x17 8.6 9.6 0x08 24.6 25.6 0x18 9.6 10.6 0x09 10.6 11.6 0x0a 11.6 12.6 0x0b 12.6 13.6 0x0c 13.6 14.6 0x0d 14.6 15.6 0x0e 15.6 16.6 0x0f
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 838 freescale semiconductor 25.3.2.2 flash security register (fsec) the fsec register holds all bits associated with the security of the mcu and flash module. all bits in the fsec register are readable but not writable. during the reset sequence, the fsec register is loaded with the contents of the flash security byte in the flash con?uration ?ld at global address 0x3_ff0f located in p-flash memory (see table 25-4 ) as indicated by reset condition f in figure 25-6 . if a double bit fault is detected while reading the p-flash phrase containing the flash security byte during the reset sequence, all bits in the fsec register will be set to leave the flash module in a secured state with backdoor key access disabled. offset module base + 0x0001 76543210 r keyen[1:0] rnv[5:2] sec[1:0] w reset f 1 1 loaded from ifr flash con?uration ?ld, during reset sequence. f 1 f 1 f 1 f 1 f 1 f 1 f 1 = unimplemented or reserved figure 25-6. flash security register (fsec) table 25-9. fsec field descriptions field description 7? keyen[1:0] backdoor key security enable bits the keyen[1:0] bits de?e the enabling of backdoor key access to the flash module as shown in table 25-10 . 5? rnv[5:2] reserved nonvolatile bits ?the rnv bits should remain in the erased state for future enhancements. 1? sec[1:0] flash security bits ?the sec[1:0] bits de?e the security state of the mcu as shown in table 25-11 . if the flash module is unsecured using backdoor key access, the sec bits are forced to 10. table 25-10. flash keyen states keyen[1:0] status of backdoor key access 00 disabled 01 disabled 1 1 preferred keyen state to disable backdoor key access. 10 enabled 11 disabled
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 839 the security function in the flash module is described in section 25.5 . 25.3.2.3 flash ccob index register (fccobix) the fccobix register is used to index the fccob register for flash memory operations. ccobix bits are readable and writable while remaining bits read 0 and are not writable. 25.3.2.4 flash reserved0 register (frsv0) this flash register is reserved for factory testing. all bits in the frsv0 register read 0 and are not writable. table 25-11. flash security states sec[1:0] status of security 00 secured 01 secured 1 1 preferred sec state to set mcu to secured state. 10 unsecured 11 secured offset module base + 0x0002 76543210 r00000 ccobix[2:0] w reset 00000000 = unimplemented or reserved figure 25-7. fccob index register (fccobix) table 25-12. fccobix field descriptions field description 2? ccobix[1:0] common command register index the ccobix bits are used to select which word of the fccob register array is being read or written to. see 25.3.2.11 flash common command object register (fccob), for more details. offset module base + 0x000c 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 25-8. flash reserved0 register (frsv0)
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 840 freescale semiconductor 25.3.2.5 flash con?uration register (fcnfg) the fcnfg register enables the flash command complete interrupt and forces ecc faults on flash array read access from the cpu. ccie, ignsf, fdfd, and fsfd bits are readable and writable while remaining bits read 0 and are not writable. 25.3.2.6 flash error con?uration register (fercnfg) the fercnfg register enables the flash error interrupts for the ferstat ?gs. offset module base + 0x0004 76543210 r ccie 00 ignsf 00 fdfd fsfd w reset 00000000 = unimplemented or reserved figure 25-9. flash con?uration register (fcnfg) table 25-13. fcnfg field descriptions field description 7 ccie command complete interrupt enable ?the ccie bit controls interrupt generation when a flash command has completed. 0 command complete interrupt disabled 1 an interrupt will be requested whenever the ccif ?g in the fstat register is set (see section 25.3.2.7 ) 4 ignsf ignore single bit fault ?the ignsf controls single bit fault reporting in the ferstat register (see section 25.3.2.8 ). 0 all single bit faults detected during array reads are reported 1 single bit faults detected during array reads are not reported and the single bit fault interrupt will not be generated 1 fdfd force double bit fault detect the fdfd bit allows the user to simulate a double bit fault during flash array read operations and check the associated interrupt routine. the fdfd bit is cleared by writing a 0 to fdfd. 0 flash array read operations will set the dfdif ?g in the ferstat register only if a double bit fault is detected 1 any flash array read operation will force the dfdif ?g in the ferstat register to be set (see section 25.3.2.7 ) and an interrupt will be generated as long as the dfdie interrupt enable in the fercnfg register is set (see section 25.3.2.6 ) 0 fsfd force single bit fault detect the fsfd bit allows the user to simulate a single bit fault during flash array read operations and check the associated interrupt routine. the fsfd bit is cleared by writing a 0 to fsfd. 0 flash array read operations will set the sfdif ?g in the ferstat register only if a single bit fault is detected 1 flash array read operation will force the sfdif ?g in the ferstat register to be set (see section 25.3.2.7 ) and an interrupt will be generated as long as the sfdie interrupt enable in the fercnfg register is set (see section 25.3.2.6 )
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 841 all assigned bits in the fercnfg register are readable and writable. 25.3.2.7 flash status register (fstat) the fstat register reports the operational status of the flash module. ccif, accerr, and fpviol bits are readable and writable, mgbusy and mgstat bits are readable but not writable, while remaining bits read 0 and are not writable. offset module base + 0x0005 76543210 r000000 dfdie sfdie w reset 00000000 = unimplemented or reserved figure 25-10. flash error con?uration register (fercnfg) table 25-14. fercnfg field descriptions field description 1 dfdie double bit fault detect interrupt enable the dfdie bit controls interrupt generation when a double bit fault is detected during a flash block read operation. 0 dfdif interrupt disabled 1 an interrupt will be requested whenever the dfdif ?g is set (see section 25.3.2.8 ) 0 sfdie single bit fault detect interrupt enable the sfdie bit controls interrupt generation when a single bit fault is detected during a flash block read operation. 0 sfdif interrupt disabled whenever the sfdif ?g is set (see section 25.3.2.8 ) 1 an interrupt will be requested whenever the sfdif ?g is set (see section 25.3.2.8 ) offset module base + 0x0006 76543210 r ccif 0 accerr fpviol mgbusy rsvd mgstat[1:0] w reset 1000000 1 1 reset value can deviate from the value shown if a double bit fault is detected during the reset sequence (see section 25.6 ). 0 1 = unimplemented or reserved figure 25-11. flash status register (fstat)
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 842 freescale semiconductor 25.3.2.8 flash error status register (ferstat) the ferstat register re?cts the error status of internal flash operations. all ?gs in the ferstat register are readable and only writable to clear the ?g. table 25-15. fstat field descriptions field description 7 ccif command complete interrupt flag ?the ccif ?g indicates that a flash command has completed. the ccif ?g is cleared by writing a 1 to ccif to launch a command and ccif will stay low until command completion or command violation. 0 flash command in progress 1 flash command has completed 5 accerr flash access error flag ?the accerr bit indicates an illegal access has occurred to the flash memory caused by either a violation of the command write sequence (see section 25.4.4.2 ) or issuing an illegal flash command. while accerr is set, the ccif ?g cannot be cleared to launch a command. the accerr bit is cleared by writing a 1 to accerr. writing a 0 to the accerr bit has no effect on accerr. 0 no access error detected 1 access error detected 4 fpviol flash protection violation flag ?he fpviol bit indicates an attempt was made to program or erase an address in a protected area of p-flash or eeprom memory during a command write sequence. the fpviol bit is cleared by writing a 1 to fpviol. writing a 0 to the fpviol bit has no effect on fpviol. while fpviol is set, it is not possible to launch a command or start a command write sequence. 0 no protection violation detected 1 protection violation detected 3 mgbusy memory controller busy flag ?the mgbusy ?g re?cts the active state of the memory controller . 0 memory controller is idle 1 memory controller is busy executing a flash command (ccif = 0) 2 rsvd reserved bit ?this bit is reserved and always reads 0 . 1? mgstat[1:0] memory controller command completion status flag one or more mgstat ?g bits are set if an error is detected during execution of a flash command or during the flash reset sequence. see section 25.4.6, ?lash command description , and section 25.6, ?nitialization ?for details. offset module base + 0x0007 76543210 r000000 dfdif sfdif w reset 00000000 = unimplemented or reserved figure 25-12. flash error status register (ferstat)
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 843 25.3.2.9 p-flash protection register (fprot) the fprot register de?es which p-flash sectors are protected against program and erase operations. the (unreserved) bits of the fprot register are writable with the restriction that the size of the protected region can only be increased (see section 25.3.2.9.1, ?-flash protection restrictions , and table 25-21 ). during the reset sequence, the fprot register is loaded with the contents of the p-flash protection byte in the flash con?uration ?ld at global address 0x3_ff0c located in p-flash memory (see table 25-4 ) as indicated by reset condition ??in figure 25-13 . to change the p-flash protection that will be loaded during the reset sequence, the upper sector of the p-flash memory must be unprotected, then the p-flash protection byte must be reprogrammed. if a double bit fault is detected while reading the p-flash phrase containing the p-flash protection byte during the reset sequence, the fpopen bit will be cleared and remaining bits in the fprot register will be set to leave the p-flash memory fully protected. table 25-16. ferstat field descriptions field description 1 dfdif double bit fault detect interrupt flag ?the setting of the dfdif ?g indicates that a double bit fault was detected in the stored parity and data bits during a flash array read operation or that a flash array read operation returning invalid data was attempted on a flash block that was under a flash command operation. 1 the dfdif ?g is cleared by writing a 1 to dfdif. writing a 0 to dfdif has no effect on dfdif. 2 0 no double bit fault detected 1 double bit fault detected or a flash array read operation returning invalid data was attempted while command running 1 the single bit fault and double bit fault ?gs are mutually exclusive for parity errors (an ecc fault occurrence can be either single fault or double fault but never both). a simultaneous access collision (flash array read operation returning invalid data attempted while command running) is indicated when both sfdif and dfdif ?gs are high. 2 there is a one cycle delay in storing the ecc dfdif and sfdif fault ?gs in this register. at least one nop is required after a ?sh memory read before checking ferstat for the occurrence of ecc errors. 0 sfdif single bit fault detect interrupt flag ?with the ignsf bit in the fcnfg register clear, the sfdif ?g indicates that a single bit fault was detected in the stored parity and data bits during a flash array read operation or that a flash array read operation returning invalid data was attempted on a flash block that was under a flash command operation. 1 the sfdif ?g is cleared by writing a 1 to sfdif. writing a 0 to sfdif has no effect on sfdif. 0 no single bit fault detected 1 single bit fault detected and corrected or a flash array read operation returning invalid data was attempted while command running offset module base + 0x0008 76543210 r fpopen rnv6 fphdis fphs[1:0] fpldis fpls[1:0] w reset f 1 1 loaded from ifr flash con?uration ?ld, during reset sequence. f 1 f 1 f 1 f 1 f 1 f 1 f 1 = unimplemented or reserved figure 25-13. flash protection register (fprot)
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 844 freescale semiconductor trying to alter data in any protected area in the p-flash memory will result in a protection violation error and the fpviol bit will be set in the fstat register. the block erase of a p-flash block is not possible if any of the p-flash sectors contained in the same p-flash block are protected. table 25-17. fprot field descriptions field description 7 fpopen flash protection operation enable ?the fpopen bit determines the protection function for program or erase operations as shown in table 25-18 for the p-flash block. 0 when fpopen is clear, the fphdis and fpldis bits de?e unprotected address ranges as speci?d by the corresponding fphs and fpls bits 1 when fpopen is set, the fphdis and fpldis bits enable protection for the address range speci?d by the corresponding fphs and fpls bits 6 rnv[6] reserved nonvolatile bit ?the rnv bit should remain in the erased state for future enhancements. 5 fphdis flash protection higher address range disable ?the fphdis bit determines whether there is a protected/unprotected area in a speci? region of the p-flash memory ending with global address 0x3_ffff. 0 protection/unprotection enabled 1 protection/unprotection disabled 4? fphs[1:0] flash protection higher address size the fphs bits determine the size of the protected/unprotected area in p-flash memory as shown in table 25-19 . the fphs bits can only be written to while the fphdis bit is set. 2 fpldis flash protection lower address range disable ?the fpldis bit determines whether there is a protected/unprotected area in a speci? region of the p-flash memory beginning with global address 0x3_8000. 0 protection/unprotection enabled 1 protection/unprotection disabled 1? fpls[1:0] flash protection lower address size the fpls bits determine the size of the protected/unprotected area in p-flash memory as shown in table 25-20 . the fpls bits can only be written to while the fpldis bit is set. table 25-18. p-flash protection function fpopen fphdis fpldis function 1 1 for range sizes, refer to table 25-19 and table 25-20 . 1 1 1 no p-flash protection 1 1 0 protected low range 1 0 1 protected high range 1 0 0 protected high and low ranges 0 1 1 full p-flash memory protected 0 1 0 unprotected low range 0 0 1 unprotected high range 0 0 0 unprotected high and low ranges
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 845 all possible p-flash protection scenarios are shown in figure 25-14 . although the protection scheme is loaded from the flash memory at global address 0x3_ff0c during the reset sequence, it can be changed by the user. the p-flash protection scheme can be used by applications requiring reprogramming in single chip mode while providing as much protection as possible if reprogramming is not required. table 25-19. p-flash protection higher address range fphs[1:0] global address range protected size 00 0x3_f800?x3_ffff 2 kbytes 01 0x3_f000?x3_ffff 4 kbytes 10 0x3_e000?x3_ffff 8 kbytes 11 0x3_c000?x3_ffff 16 kbytes table 25-20. p-flash protection lower address range fpls[1:0] global address range protected size 00 0x3_8000?x3_83ff 1 kbyte 01 0x3_8000?x3_87ff 2 kbytes 10 0x3_8000?x3_8fff 4 kbytes 11 0x3_8000?x3_9fff 8 kbytes
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 846 freescale semiconductor figure 25-14. p-flash protection scenarios 7 6 5 4 fphs[1:0] fpls[1:0] 3 2 1 0 fphs[1:0] fpls[1:0] fphdis = 1 fpldis = 1 fphdis = 1 fpldis = 0 fphdis = 0 fpldis = 1 fphdis = 0 fpldis = 0 scenario scenario unprotected region protected region with size protected region protected region with size defined by fpls defined by fphs not defined by fpls, fphs 0x3_8000 0x3_ffff 0x3_8000 0x3_ffff flash start flash start fpopen = 1 fpopen = 0
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 847 25.3.2.9.1 p-flash protection restrictions the general guideline is that p-flash protection can only be added and not removed. table 25-21 speci?s all valid transitions between p-flash protection scenarios. any attempt to write an invalid scenario to the fprot register will be ignored. the contents of the fprot register re?ct the active protection scenario. see the fphs and fpls bit descriptions for additional restrictions. 25.3.2.10 eeprom protection register (eeprot) the eeprot register de?es which eeprom sectors are protected against program and erase operations. the (unreserved) bits of the eeprot register are writable with the restriction that protection can be added but not removed. writes must increase the dps value and the dpopen bit can only be written from 1 (protection disabled) to 0 (protection enabled). if the dpopen bit is set, the state of the dps bits is irrelevant. table 25-21. p-flash protection scenario transitions from protection scenario to protection scenario 1 1 allowed transitions marked with x, see figure 25-14 for a de?ition of the scenarios. 01234567 0 xxxx 1 xx 2 xx 3 x 4 xx 5 xxxx 6 xxxx 7 xxxxxxxx offset module base + 0x0009 76543210 r dpopen 00 dps[4:0] w reset f 1 1 loaded from ifr flash con?uration ?ld, during reset sequence. 00f 1 f 1 f 1 f 1 f 1 = unimplemented or reserved figure 25-15. eeprom protection register (eeprot)
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 848 freescale semiconductor during the reset sequence, ?lds dpopen and dps of the eeprot register are loaded with the contents of the eeprom protection byte in the flash configuration field at global address 0x3_ff0d located in p-flash memory (see table 25-4 ) as indicated by reset condition f in table 25-23 . to change the eeprom protection that will be loaded during the reset sequence, the p-flash sector containing the eeprom protection byte must be unprotected, then the eeprom protection byte must be programmed. if a double bit fault is detected while reading the p-flash phrase containing the eeprom protection byte during the reset sequence, the dpopen bit will be cleared and dps bits will be set to leave the eeprom memory fully protected. trying to alter data in any protected area in the eeprom memory will result in a protection violation error and the fpviol bit will be set in the fstat register. block erase of the eeprom memory is not possible if any of the eeprom sectors are protected. table 25-22. eeprot field descriptions field description 7 dpopen eeprom protection control 0 enables eeprom memory protection from program and erase with protected address range de?ed by dps bits 1 disables eeprom memory protection from program and erase 4? dps[4:0] eeprom protection size ?the dps[4:0] bits determine the size of the protected area in the eeprom memory as shown in table 25-23 . table 25-23. eeprom protection address range dps[4:0] global address range protected size 00000 0x0_0400 ?0x0_041f 32 bytes 00001 0x0_0400 ?0x0_043f 64 bytes 00010 0x0_0400 ?0x0_045f 96 bytes 00011 0x0_0400 ?0x0_047f 128 bytes 00100 0x0_0400 ?0x0_049f 160 bytes 00101 0x0_0400 ?0x0_04bf 192 bytes the protection size goes on enlarging in step of 32 bytes, for each dps value increasing of one. . . . 11111 - to - 11111 0x0_0400 ?0x0_07ff 1,024 bytes
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 849 25.3.2.11 flash common command object register (fccob) the fccob is an array of six words addressed via the ccobix index found in the fccobix register. byte wide reads and writes are allowed to the fccob register. 25.3.2.11.1 fccob - nvm command mode nvm command mode uses the indexed fccob register to provide a command code and its relevant parameters to the memory controller. the user ?st sets up all required fccob ?lds and then initiates the commands execution by writing a 1 to the ccif bit in the fstat register (a 1 written by the user clears the ccif command completion ?g to 0). when the user clears the ccif bit in the fstat register all fccob parameter ?lds are locked and cannot be changed by the user until the command completes (as evidenced by the memory controller returning ccif to 1). some commands return information to the fccob register array. the generic format for the fccob parameter ?lds in nvm command mode is shown in table 25-24 . the return values are available for reading after the ccif ?g in the fstat register has been returned to 1 by the memory controller. writes to the unimplemented parameter ?lds (ccobix = 110 and ccobix = 111) are ignored with reads from these ?lds returning 0x0000. table 25-24 shows the generic flash command format. the high byte of the ?st word in the ccob array contains the command code, followed by the parameters for this speci? flash command. for details on the fccob settings required by each command, see the flash command descriptions in section 25.4.6 . offset module base + 0x000a 76543210 r ccob[15:8] w reset 00000000 figure 25-16. flash common command object high register (fccobhi) offset module base + 0x000b 76543210 r ccob[7:0] w reset 00000000 figure 25-17. flash common command object low register (fccoblo) table 25-24. fccob - nvm command mode (typical usage) ccobix[2:0] byte fccob parameter fields (nvm command mode) 000 hi fcmd[7:0] de?ing flash command lo 6?0, global address [17:16] 001 hi global address [15:8] lo global address [7:0]
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 850 freescale semiconductor 25.3.2.12 flash reserved1 register (frsv1) this flash register is reserved for factory testing. all bits in the frsv1 register read 0 and are not writable. 25.3.2.13 flash reserved2 register (frsv2) this flash register is reserved for factory testing. all bits in the frsv2 register read 0 and are not writable. 25.3.2.14 flash reserved3 register (frsv3) this flash register is reserved for factory testing. 010 hi data 0 [15:8] lo data 0 [7:0] 011 hi data 1 [15:8] lo data 1 [7:0] 100 hi data 2 [15:8] lo data 2 [7:0] 101 hi data 3 [15:8] lo data 3 [7:0] offset module base + 0x000c 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 25-18. flash reserved1 register (frsv1) offset module base + 0x000d 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 25-19. flash reserved2 register (frsv2) table 25-24. fccob - nvm command mode (typical usage) ccobix[2:0] byte fccob parameter fields (nvm command mode)
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 851 all bits in the frsv3 register read 0 and are not writable. 25.3.2.15 flash reserved4 register (frsv4) this flash register is reserved for factory testing. all bits in the frsv4 register read 0 and are not writable. 25.3.2.16 flash option register (fopt) the fopt register is the flash option register. all bits in the fopt register are readable but are not writable. during the reset sequence, the fopt register is loaded from the flash nonvolatile byte in the flash con?uration ?ld at global address 0x3_ff0e located in p-flash memory (see table 25-4 ) as indicated by reset condition f in figure 25-22 . if a double bit fault is detected while reading the p-flash phrase containing the flash nonvolatile byte during the reset sequence, all bits in the fopt register will be set. offset module base + 0x000e 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 25-20. flash reserved3 register (frsv3) offset module base + 0x000f 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 25-21. flash reserved4 register (frsv4) offset module base + 0x0010 76543210 r nv[7:0] w reset f 1 1 loaded from ifr flash con?uration ?ld, during reset sequence. f 1 f 1 f 1 f 1 f 1 f 1 f 1 = unimplemented or reserved figure 25-22. flash option register (fopt)
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 852 freescale semiconductor 25.3.2.17 flash reserved5 register (frsv5) this flash register is reserved for factory testing. all bits in the frsv5 register read 0 and are not writable. 25.3.2.18 flash reserved6 register (frsv6) this flash register is reserved for factory testing. all bits in the frsv6 register read 0 and are not writable. 25.3.2.19 flash reserved7 register (frsv7) this flash register is reserved for factory testing. table 25-25. fopt field descriptions field description 7? nv[7:0] nonvolatile bits the nv[7:0] bits are available as nonvolatile bits. refer to the device user guide for proper use of the nv bits. offset module base + 0x0011 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 25-23. flash reserved5 register (frsv5) offset module base + 0x0012 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 25-24. flash reserved6 register (frsv6)
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 853 all bits in the frsv7 register read 0 and are not writable. 25.4 functional description 25.4.1 modes of operation the ftmrg32k1 module provides the modes of operation normal and special . the operating mode is determined by module-level inputs and affects the fclkdiv, fcnfg, and eeprot registers (see table 25-27 ). 25.4.2 ifr version id word the version id word is stored in the ifr at address 0x0_40b6. the contents of the word are de?ed in table 25-26 . vernum: version number. the ?st version is number 0b_0001 with both 0b_0000 and 0b_1111 meaning ?one? offset module base + 0x0013 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 25-25. flash reserved7 register (frsv7) table 25-26. ifr version id fields [15:4] [3:0] reserved vernum
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 854 freescale semiconductor 25.4.3 internal nvm resource (nvmres) ifr is an internal nvm resource readable by cpu , when nvmres is active. the ifr ?lds are shown in table 25-5 . the nvmres global address map is shown in table 25-6 . 25.4.4 flash command operations flash command operations are used to modify flash memory contents. the next sections describe: how to write the fclkdiv register that is used to generate a time base (fclk) derived from busclk for flash program and erase command operations the command write sequence used to set flash command parameters and launch execution valid flash commands available for execution, according to mcu functional mode and mcu security state. 25.4.4.1 writing the fclkdiv register prior to issuing any flash program or erase command after a reset, the user is required to write the fclkdiv register to divide busclk down to a target fclk of 1 mhz. table 25-8 shows recommended values for the fdiv ?ld based on busclk frequency. note programming or erasing the flash memory cannot be performed if the bus clock runs at less than 0.8 mhz. setting fdiv too high can destroy the flash memory due to overstress. setting fdiv too low can result in incomplete programming or erasure of the flash memory cells. when the fclkdiv register is written, the fdivld bit is set automatically. if the fdivld bit is 0, the fclkdiv register has not been written since the last reset. if the fclkdiv register has not been written, any flash program or erase command loaded during a command write sequence will not execute and the accerr bit in the fstat register will set. 25.4.4.2 command write sequence the memory controller will launch all valid flash commands entered using a command write sequence. before launching a command, the accerr and fpviol bits in the fstat register must be clear (see section 25.3.2.7 ) and the ccif ?g should be tested to determine the status of the current command write sequence. if ccif is 0, the previous command write sequence is still active, a new command write sequence cannot be started, and all writes to the fccob register are ignored.
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 855 25.4.4.2.1 de?e fccob contents the fccob parameter ?lds must be loaded with all required parameters for the flash command being executed. access to the fccob parameter ?lds is controlled via the ccobix bits in the fccobix register (see section 25.3.2.3 ). the contents of the fccob parameter ?lds are transferred to the memory controller when the user clears the ccif command completion ?g in the fstat register (writing 1 clears the ccif to 0). the ccif ?g will remain clear until the flash command has completed. upon completion, the memory controller will return ccif to 1 and the fccob register will be used to communicate any results. the ?w for a generic command write sequence is shown in figure 25-26 .
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 856 freescale semiconductor figure 25-26. generic flash command write sequence flowchart write to fccobix register write: fstat register (to launch command) clear ccif 0x80 clear accerr/fpviol 0x30 write: fstat register yes no access error and protection violation read: fstat register start check fccob accerr/ fpviol set? exit write: fclkdiv register read: fclkdiv register yes no fdiv correct? no bit polling for command completion check yes ccif set? to identify speci? command parameter to load. write to fccob register to load required command parameter. yes no more parameters? availability check results from previous command note: fclkdiv must be set after each reset read: fstat register no yes ccif set? no yes ccif set? clock divider value check read: fstat register
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 857 25.4.4.3 valid flash module commands table 25-27 present the valid flash commands, as enabled by the combination of the functional mcu mode (normal singlechip ns, special singlechip ss) with the mcu security state (unsecured, secured). special singlechip mode is selected by input mmc_ss_mode_ts2 asserted. mcu secured state is selected by input mmc_secure input asserted. + 25.4.4.4 p-flash commands table 25-28 summarizes the valid p-flash commands along with the effects of the commands on the p-flash block and other resources within the flash module. table 25-27. flash commands by mode and security state fcmd command unsecured secured ns 1 1 unsecured normal single chip mode ss 2 2 unsecured special single chip mode. ns 3 3 secured normal single chip mode. ss 4 4 secured special single chip mode. 0x01 erase verify all blocks ???? 0x02 erase verify block ???? 0x03 erase verify p-flash section ??? 0x04 read once ??? 0x06 program p-flash ??? 0x07 program once ??? 0x08 erase all blocks ?? 0x09 erase flash block ??? 0x0a erase p-flash sector ??? 0x0b unsecure flash ?? 0x0c verify backdoor access key ?? 0x0d set user margin level ??? 0x0e set field margin level ? 0x10 erase verify eeprom section ??? 0x11 program eeprom ??? 0x12 erase eeprom sector ??? table 25-28. p-flash commands fcmd command function on p-flash memory 0x01 erase verify all blocks verify that all p-flash (and eeprom) blocks are erased.
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 858 freescale semiconductor 25.4.4.5 eeprom commands table 25-29 summarizes the valid eeprom commands along with the effects of the commands on the eeprom block. 0x02 erase verify block verify that a p-flash block is erased. 0x03 erase verify p-flash section verify that a given number of words starting at the address provided are erased. 0x04 read once read a dedicated 64 byte ?ld in the nonvolatile information register in p-flash block that was previously programmed using the program once command. 0x06 program p-flash program a phrase in a p-flash block. 0x07 program once program a dedicated 64 byte ?ld in the nonvolatile information register in p-flash block that is allowed to be programmed only once. 0x08 erase all blocks erase all p-flash (and eeprom) blocks. an erase of all flash blocks is only possible when the fpldis, fphdis, and fpopen bits in the fprot register and the dpopen bit in the eeprot register are set prior to launching the command. 0x09 erase flash block erase a p-flash (or eeprom) block. an erase of the full p-flash block is only possible when fpldis, fphdis and fpopen bits in the fprot register are set prior to launching the command. 0x0a erase p-flash sector erase all bytes in a p-flash sector. 0x0b unsecure flash supports a method of releasing mcu security by erasing all p-flash (and eeprom) blocks and verifying that all p-flash (and eeprom) blocks are erased. 0x0c verify backdoor access key supports a method of releasing mcu security by verifying a set of security keys. 0x0d set user margin level speci?s a user margin read level for all p-flash blocks. 0x0e set field margin level speci?s a ?ld margin read level for all p-flash blocks (special modes only). table 25-29. eeprom commands fcmd command function on eeprom memory 0x01 erase verify all blocks verify that all eeprom (and p-flash) blocks are erased. 0x02 erase verify block verify that the eeprom block is erased. table 25-28. p-flash commands fcmd command function on p-flash memory
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 859 25.4.5 allowed simultaneous p-flash and eeprom operations only the operations marked ?k?in table 25-30 are permitted to be run simultaneously on the program flash and eeprom blocks. some operations cannot be executed simultaneously because certain hardware resources are shared by the two memories. the priority has been placed on permitting program flash reads while program and erase operations execute on the eeprom, providing read (p-flash) while write (eeprom) functionality. 0x08 erase all blocks erase all eeprom (and p-flash) blocks. an erase of all flash blocks is only possible when the fpldis, fphdis, and fpopen bits in the fprot register and the dpopen bit in the eeprot register are set prior to launching the command. 0x09 erase flash block erase a eeprom (or p-flash) block. an erase of the full eeprom block is only possible when dpopen bit in the eeprot register is set prior to launching the command. 0x0b unsecure flash supports a method of releasing mcu security by erasing all eeprom (and p-flash) blocks and verifying that all eeprom (and p-flash) blocks are erased. 0x0d set user margin level speci?s a user margin read level for the eeprom block. 0x0e set field margin level speci?s a ?ld margin read level for the eeprom block (special modes only). 0x10 erase verify eeprom section verify that a given number of words starting at the address provided are erased. 0x11 program eeprom program up to four words in the eeprom block. 0x12 erase eeprom sector erase all bytes in a sector of the eeprom block. table 25-30. allowed p-flash and eeprom simultaneous operations eeprom program flash read margin read 1 program sector erase mass erase 2 read ok ok ok margin read 1 1 a ?argin read?is any read after executing the margin setting commands ?et user margin level?or ?et field margin level?with anything but the ?ormal level speci?d. see the note on margin settings in section 25.4.6.12 and section 25.4.6.13 . program sector erase mass erase 2 2 the ?ass erase?operations are commands ?rase all blocks?and ?rase flash block ok table 25-29. eeprom commands fcmd command function on eeprom memory
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 860 freescale semiconductor 25.4.6 flash command description this section provides details of all available flash commands launched by a command write sequence. the accerr bit in the fstat register will be set during the command write sequence if any of the following illegal steps are performed, causing the command not to be processed by the memory controller: starting any command write sequence that programs or erases flash memory before initializing the fclkdiv register writing an invalid command as part of the command write sequence for additional possible errors, refer to the error handling table provided for each command if a flash block is read during execution of an algorithm (ccif = 0) on that same block, the read operation will return invalid data if both ?gs sfdif and dfdif are set. if the sfdif or dfdif ?gs were not previously set when the invalid read operation occurred, both the sfdif and dfdif ?gs will be set. if the accerr or fpviol bits are set in the fstat register, the user must clear these bits before starting any command write sequence (see section 25.3.2.7 ). caution a flash word or phrase must be in the erased state before being programmed. cumulative programming of bits within a flash word or phrase is not allowed. 25.4.6.1 erase verify all blocks command the erase verify all blocks command will verify that all p-flash and eeprom blocks have been erased. upon clearing ccif to launch the erase verify all blocks command, the memory controller will verify that the entire flash memory space is erased. the ccif ?g will set after the erase verify all blocks operation has completed. if all blocks are not erased, it means blank check failed, both mgstat bits will be set. table 25-31. erase verify all blocks command fccob requirements ccobix[2:0] fccob parameters 000 0x01 not required table 25-32. erase verify all blocks command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 000 at command launch fpviol none mgstat1 set if any errors have been encountered during the read 1 or if blank check failed . 1 as found in the memory map for ftmrg32k1. mgstat0 set if any non-correctable errors have been encountered during the read 1 or if blank check failed.
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 861 25.4.6.2 erase verify block command the erase verify block command allows the user to verify that an entire p-flash or eeprom block has been erased. the fccob flashblockselectioncode[1:0] bits determine which block must be veri?d. upon clearing ccif to launch the erase verify block command, the memory controller will verify that the selected p-flash or eeprom block is erased. the ccif ?g will set after the erase verify block operation has completed.if the block is not erased, it means blank check failed, both mgstat bits will be set. 25.4.6.3 erase verify p-flash section command the erase verify p-flash section command will verify that a section of code in the p-flash memory is erased. the erase verify p-flash section command de?es the starting point of the code to be veri?d and the number of phrases. table 25-33. erase verify block command fccob requirements ccobix[2:0] fccob parameters 000 0x02 flash block selection code [1:0] . see table 25-34 table 25-34. flash block selection code description selection code[1:0] flash block to be veri?d 00 eeprom 01 invalid (accerr) 10 invalid (accerr) 11 p-flash table 25-35. erase verify block command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 000 at command launch set if an invalid flashblockselectioncode[1:0] is supplied fpviol none mgstat1 set if any errors have been encountered during the read or if blank check failed. mgstat0 set if any non-correctable errors have been encountered during the read or if blank check failed.
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 862 freescale semiconductor upon clearing ccif to launch the erase verify p-flash section command, the memory controller will verify the selected section of flash memory is erased. the ccif ?g will set after the erase verify p-flash section operation has completed. if the section is not erased, it means blank check failed, both mgstat bits will be set. 25.4.6.4 read once command the read once command provides read access to a reserved 64 byte ?ld (8 phrases) located in the nonvolatile information register of p-flash. the read once ?ld is programmed using the program once command described in section 25.4.6.6 . the read once command must not be executed from the flash block containing the program once reserved ?ld to avoid code runaway. table 25-36. erase verify p-flash section command fccob requirements ccobix[2:0] fccob parameters 000 0x03 global address [17:16] of a p-flash block 001 global address [15:0] of the ?st phrase to be veri?d 010 number of phrases to be veri?d table 25-37. erase verify p-flash section command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 010 at command launch set if command not available in current mode (see table 25-27 ) set if an invalid global address [17:0] is supplied see table 25-3 ) set if a misaligned phrase address is supplied (global address [2:0] != 000) set if the requested section crosses a the p-flash address boundary fpviol none mgstat1 set if any errors have been encountered during the read or if blank check failed. mgstat0 set if any non-correctable errors have been encountered during the read or if blank check failed. table 25-38. read once command fccob requirements ccobix[2:0] fccob parameters 000 0x04 not required 001 read once phrase index (0x0000 - 0x0007) 010 read once word 0 value 011 read once word 1 value 100 read once word 2 value 101 read once word 3 value
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 863 upon clearing ccif to launch the read once command, a read once phrase is fetched and stored in the fccob indexed register. the ccif ?g will set after the read once operation has completed. valid phrase index values for the read once command range from 0x0000 to 0x0007. during execution of the read once command, any attempt to read addresses within p-flash block will return invalid data. 8 25.4.6.5 program p-flash command the program p-flash operation will program a previously erased phrase in the p-flash memory using an embedded algorithm. caution a p-flash phrase must be in the erased state before being programmed. cumulative programming of bits within a flash phrase is not allowed. upon clearing ccif to launch the program p-flash command, the memory controller will program the data words to the supplied global address and will then proceed to verify the data words read back as expected. the ccif ?g will set after the program p-flash operation has completed. table 25-39. read once command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 25-27 ) set if an invalid phrase index is supplied fpviol none mgstat1 set if any errors have been encountered during the read mgstat0 set if any non-correctable errors have been encountered during the read table 25-40. program p-flash command fccob requirements ccobix[2:0] fccob parameters 000 0x06 global address [17:16] to identify p-flash block 001 global address [15:0] of phrase location to be programmed 1 1 global address [2:0] must be 000 010 word 0 program value 011 word 1 program value 100 word 2 program value 101 word 3 program value
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 864 freescale semiconductor 25.4.6.6 program once command the program once command restricts programming to a reserved 64 byte ?ld (8 phrases) in the nonvolatile information register located in p-flash. the program once reserved ?ld can be read using the read once command as described in section 25.4.6.4 . the program once command must only be issued once since the nonvolatile information register in p-flash cannot be erased. the program once command must not be executed from the flash block containing the program once reserved ?ld to avoid code runaway. upon clearing ccif to launch the program once command, the memory controller ?st veri?s that the selected phrase is erased. if erased, then the selected phrase will be programmed and then veri?d with read back. the ccif ?g will remain clear, setting only after the program once operation has completed. the reserved nonvolatile information register accessed by the program once command cannot be erased and any attempt to program one of these phrases a second time will not be allowed. valid phrase index values for the program once command range from 0x0000 to 0x0007. during execution of the program once command, any attempt to read addresses within p-flash will return invalid data. table 25-41. program p-flash command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 101 at command launch set if command not available in current mode (see table 25-27 ) set if an invalid global address [17:0] is supplied see table 25-3 ) set if a misaligned phrase address is supplied (global address [2:0] != 000) fpviol set if the global address [17:0] points to a protected area mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation table 25-42. program once command fccob requirements ccobix[2:0] fccob parameters 000 0x07 not required 001 program once phrase index (0x0000 - 0x0007) 010 program once word 0 value 011 program once word 1 value 100 program once word 2 value 101 program once word 3 value
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 865 25.4.6.7 erase all blocks command the erase all blocks operation will erase the entire p-flash and eeprom memory space. upon clearing ccif to launch the erase all blocks command, the memory controller will erase the entire flash memory space and verify that it is erased. if the memory controller veri?s that the entire flash memory space was properly erased, security will be released. during the execution of this command (ccif=0) the user must not write to any flash module register. the ccif ?g will set after the erase all blocks operation has completed. 25.4.6.8 erase flash block command the erase flash block operation will erase all addresses in a p-flash or eeprom block. table 25-43. program once command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 101 at command launch set if command not available in current mode (see table 25-27 ) set if an invalid phrase index is supplied set if the requested phrase has already been programmed 1 1 if a program once phrase is initially programmed to 0xffff_ffff_ffff_ffff, the program once command will be allowed to execute again on that same phrase. fpviol none mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation table 25-44. erase all blocks command fccob requirements ccobix[2:0] fccob parameters 000 0x08 not required table 25-45. erase all blocks command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 000 at command launch set if command not available in current mode (see table 25-27 ) fpviol set if any area of the p-flash or eeprom memory is protected mgstat1 set if any errors have been encountered during the verify operation 1 1 as found in the memory map for ftmrg32k1. mgstat0 set if any non-correctable errors have been encountered during the verify operation
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 866 freescale semiconductor upon clearing ccif to launch the erase flash block command, the memory controller will erase the selected flash block and verify that it is erased. the ccif ?g will set after the erase flash block operation has completed. 25.4.6.9 erase p-flash sector command the erase p-flash sector operation will erase all addresses in a p-flash sector. upon clearing ccif to launch the erase p-flash sector command, the memory controller will erase the selected flash sector and then verify that it is erased. the ccif ?g will be set after the erase p-flash sector operation has completed. table 25-46. erase flash block command fccob requirements ccobix[2:0] fccob parameters 000 0x09 global address [17:16] to identify flash block 001 global address [15:0] in flash block to be erased table 25-47. erase flash block command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 25-27 ) set if an invalid global address [17:16] is supplied set if the supplied p-flash address is not phrase-aligned or if the eeprom address is not word-aligned fpviol set if an area of the selected flash block is protected mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation table 25-48. erase p-flash sector command fccob requirements ccobix[2:0] fccob parameters 000 0x0a global address [17:16] to identify p-flash block to be erased 001 global address [15:0] anywhere within the sector to be erased. refer to section 25.1.2.1 for the p-flash sector size.
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 867 25.4.6.10 unsecure flash command the unsecure flash command will erase the entire p-flash and eeprom memory space and, if the erase is successful, will release security. upon clearing ccif to launch the unsecure flash command, the memory controller will erase the entire p-flash and eeprom memory space and verify that it is erased. if the memory controller veri?s that the entire flash memory space was properly erased, security will be released. if the erase verify is not successful, the unsecure flash operation sets mgstat1 and terminates without changing the security state. during the execution of this command (ccif=0) the user must not write to any flash module register. the ccif ?g is set after the unsecure flash operation has completed. 25.4.6.11 verify backdoor access key command the verify backdoor access key command will only execute if it is enabled by the keyen bits in the fsec register (see table 25-10 ). the verify backdoor access key command releases security if table 25-49. erase p-flash sector command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 25-27 ) set if an invalid global address [17:16] is supplied see table 25-3 ) 1 1 as de?ed by the memory map for ftmrg32k1. set if a misaligned phrase address is supplied (global address [2:0] != 000) fpviol set if the selected p-flash sector is protected mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation table 25-50. unsecure flash command fccob requirements ccobix[2:0] fccob parameters 000 0x0b not required table 25-51. unsecure flash command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 000 at command launch set if command not available in current mode (see table 25-27 ) fpviol set if any area of the p-flash or eeprom memory is protected mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 868 freescale semiconductor user-supplied keys match those stored in the flash security bytes of the flash con?uration ?ld (see table 25-4 ). the verify backdoor access key command must not be executed from the flash block containing the backdoor comparison key to avoid code runaway. upon clearing ccif to launch the verify backdoor access key command, the memory controller will check the fsec keyen bits to verify that this command is enabled. if not enabled, the memory controller sets the accerr bit in the fstat register and terminates. if the command is enabled, the memory controller compares the key provided in fccob to the backdoor comparison key in the flash con?uration ?ld with key 0 compared to 0x3_ff00, etc. if the backdoor keys match, security will be released. if the backdoor keys do not match, security is not released and all future attempts to execute the verify backdoor access key command are aborted (set accerr) until a reset occurs. the ccif flag is set after the verify backdoor access key operation has completed. 25.4.6.12 set user margin level command the set user margin level command causes the memory controller to set the margin level for future read operations of the p-flash or eeprom block. table 25-52. verify backdoor access key command fccob requirements ccobix[2:0] fccob parameters 000 0x0c not required 001 key 0 010 key 1 011 key 2 100 key 3 table 25-53. verify backdoor access key command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 100 at command launch set if an incorrect backdoor key is supplied set if backdoor key access has not been enabled (keyen[1:0] != 10, see section 25.3.2.2 ) set if the backdoor key has mismatched since the last reset fpviol none mgstat1 none mgstat0 none table 25-54. set user margin level command fccob requirements ccobix[2:0] fccob parameters 000 0x0d flash block selection code [1:0] . see table 25-34 001 margin level setting.
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 869 upon clearing ccif to launch the set user margin level command, the memory controller will set the user margin level for the targeted block and then set the ccif ?g. note when the eeprom block is targeted, the eeprom user margin levels are applied only to the eeprom reads. however, when the p-flash block is targeted, the p-flash user margin levels are applied to both p-flash and eeprom reads. it is not possible to apply user margin levels to the p-flash block only. valid margin level settings for the set user margin level command are de?ed in table 25-55 . note user margin levels can be used to check that flash memory contents have adequate margin for normal level read operations. if unexpected results are encountered when checking flash memory contents at user margin levels, a potential loss of information has been detected. table 25-55. valid set user margin level settings ccob (ccobix=001) level description 0x0000 return to normal level 0x0001 user margin-1 level 1 1 read margin to the erased state 0x0002 user margin-0 level 2 2 read margin to the programmed state table 25-56. set user margin level command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 25-27 ) set if an invalid flashblockselectioncode[1:0] is supplied (see table 25-34 ) set if an invalid margin level setting is supplied fpviol none mgstat1 none mgstat0 none
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 870 freescale semiconductor 25.4.6.13 set field margin level command the set field margin level command, valid in special modes only, causes the memory controller to set the margin level speci?d for future read operations of the p-flash or eeprom block. upon clearing ccif to launch the set field margin level command, the memory controller will set the ?ld margin level for the targeted block and then set the ccif ?g. note when the eeprom block is targeted, the eeprom ?ld margin levels are applied only to the eeprom reads. however, when the p-flash block is targeted, the p-flash ?ld margin levels are applied to both p-flash and eeprom reads. it is not possible to apply ?ld margin levels to the p-flash block only. valid margin level settings for the set field margin level command are de?ed in table 25-58 . table 25-57. set field margin level command fccob requirements ccobix[2:0] fccob parameters 000 0x0e flash block selection code [1:0] . see table 25-34 001 margin level setting. table 25-58. valid set field margin level settings ccob (ccobix=001) level description 0x0000 return to normal level 0x0001 user margin-1 level 1 1 read margin to the erased state 0x0002 user margin-0 level 2 2 read margin to the programmed state 0x0003 field margin-1 level 1 0x0004 field margin-0 level 2
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 871 caution field margin levels must only be used during verify of the initial factory programming. note field margin levels can be used to check that flash memory contents have adequate margin for data retention at the normal level setting. if unexpected results are encountered when checking flash memory contents at ?ld margin levels, the flash memory contents should be erased and reprogrammed. 25.4.6.14 erase verify eeprom section command the erase verify eeprom section command will verify that a section of code in the eeprom is erased. the erase verify eeprom section command de?es the starting point of the data to be veri?d and the number of words. upon clearing ccif to launch the erase verify eeprom section command, the memory controller will verify the selected section of eeprom memory is erased. the ccif ?g will set after the erase verify eeprom section operation has completed. if the section is not erased, it means blank check failed, both mgstat bits will be set. table 25-59. set field margin level command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 25-27 ) set if an invalid flashblockselectioncode[1:0] is supplied (see table 25-34 ) set if an invalid margin level setting is supplied fpviol none mgstat1 none mgstat0 none table 25-60. erase verify eeprom section command fccob requirements ccobix[2:0] fccob parameters 000 0x10 global address [17:16] to identify the eeprom block 001 global address [15:0] of the ?st word to be veri?d 010 number of words to be veri?d
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 872 freescale semiconductor 25.4.6.15 program eeprom command the program eeprom operation programs one to four previously erased words in the eeprom block. the program eeprom operation will con?m that the targeted location(s) were successfully programmed upon completion. caution a flash word must be in the erased state before being programmed. cumulative programming of bits within a flash word is not allowed. upon clearing ccif to launch the program eeprom command, the user-supplied words will be transferred to the memory controller and be programmed if the area is unprotected. the ccobix index value at program eeprom command launch determines how many words will be programmed in the eeprom block. the ccif ?g is set when the operation has completed. table 25-61. erase verify eeprom section command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 010 at command launch set if command not available in current mode (see table 25-27 ) set if an invalid global address [17:0] is supplied set if a misaligned word address is supplied (global address [0] != 0) set if the requested section breaches the end of the eeprom block fpviol none mgstat1 set if any errors have been encountered during the read or if blank check failed. mgstat0 set if any non-correctable errors have been encountered during the read or if blank check failed. table 25-62. program eeprom command fccob requirements ccobix[2:0] fccob parameters 000 0x11 global address [17:16] to identify the eeprom block 001 global address [15:0] of word to be programmed 010 word 0 program value 011 word 1 program value, if desired 100 word 2 program value, if desired 101 word 3 program value, if desired
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 873 25.4.6.16 erase eeprom sector command the erase eeprom sector operation will erase all addresses in a sector of the eeprom block. upon clearing ccif to launch the erase eeprom sector command, the memory controller will erase the selected flash sector and verify that it is erased. the ccif ?g will set after the erase eeprom sector operation has completed. table 25-63. program eeprom command error handling register error bit error condition fstat accerr set if ccobix[2:0] < 010 at command launch set if ccobix[2:0] > 101 at command launch set if command not available in current mode (see table 25-27 ) set if an invalid global address [17:0] is supplied set if a misaligned word address is supplied (global address [0] != 0) set if the requested group of words breaches the end of the eeprom block fpviol set if the selected area of the eeprom memory is protected mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation table 25-64. erase eeprom sector command fccob requirements ccobix[2:0] fccob parameters 000 0x12 global address [17:16] to identify eeprom block 001 global address [15:0] anywhere within the sector to be erased. see section 25.1.2.2 for eeprom sector size. table 25-65. erase eeprom sector command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 25-27 ) set if an invalid global address [17:0] is suppliedsee table 25-3 ) set if a misaligned word address is supplied (global address [0] != 0) fpviol set if the selected area of the eeprom memory is protected mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 874 freescale semiconductor 25.4.7 interrupts the flash module can generate an interrupt when a flash command operation has completed or when a flash command operation has detected an ecc fault. note vector addresses and their relative interrupt priority are determined at the mcu level. 25.4.7.1 description of flash interrupt operation the flash module uses the ccif ?g in combination with the ccie interrupt enable bit to generate the flash command interrupt request. the flash module uses the dfdif and sfdif ?gs in combination with the dfdie and sfdie interrupt enable bits to generate the flash error interrupt request. for a detailed description of the register bits involved, refer to section 25.3.2.5, ?lash configuration register (fcnfg) ? section 25.3.2.6, ?lash error configuration register (fercnfg) ? section 25.3.2.7, ?lash status register (fstat) ? and section 25.3.2.8, ?lash error status register (ferstat) ? the logic used for generating the flash module interrupts is shown in figure 25-27 . figure 25-27. flash module interrupts implementation table 25-66. flash interrupt sources interrupt source interrupt flag local enable global (ccr) mask flash command complete ccif (fstat register) ccie (fcnfg register) i bit ecc double bit fault on flash read dfdif (ferstat register) dfdie (fercnfg register) i bit ecc single bit fault on flash read sfdif (ferstat register) sfdie (fercnfg register) i bit flash error interrupt request ccif ccie dfdif dfdie sfdif sfdie flash command interrupt request
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 875 25.4.8 wait mode the flash module is not affected if the mcu enters wait mode. the flash module can recover the mcu from wait via the ccif interrupt (see section 25.4.7, ?nterrupts ). 25.4.9 stop mode if a flash command is active (ccif = 0) when the mcu requests stop mode, the current flash operation will be completed before the mcu is allowed to enter stop mode. 25.5 security the flash module provides security information to the mcu. the flash security state is de?ed by the sec bits of the fsec register (see table 25-11 ). during reset, the flash module initializes the fsec register using data read from the security byte of the flash con?uration ?ld at global address 0x3_ff0f. the security state out of reset can be permanently changed by programming the security byte assuming that the mcu is starting from a mode where the necessary p-flash erase and program commands are available and that the upper region of the p-flash is unprotected. if the flash security byte is successfully programmed, its new value will take affect after the next mcu reset. the following subsections describe these security-related subjects: unsecuring the mcu using backdoor key access unsecuring the mcu in special single chip mode using bdm mode and security effects on flash command availability 25.5.1 unsecuring the mcu using backdoor key access the mcu may be unsecured by using the backdoor key access feature which requires knowledge of the contents of the backdoor keys (four 16-bit words programmed at addresses 0x3_ff00-0x3_ff07). if the keyen[1:0] bits are in the enabled state (see section 25.3.2.2 ), the verify backdoor access key command (see section 25.4.6.11 ) allows the user to present four prospective keys for comparison to the keys stored in the flash memory via the memory controller. if the keys presented in the verify backdoor access key command match the backdoor keys stored in the flash memory, the sec bits in the fsec register (see table 25-11 ) will be changed to unsecure the mcu. key values of 0x0000 and 0xffff are not permitted as backdoor keys. while the verify backdoor access key command is active, p-flash memory and eeprom memory will not be available for read access and will return invalid data.
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 876 freescale semiconductor the user code stored in the p-flash memory must have a method of receiving the backdoor keys from an external stimulus. this external stimulus would typically be through one of the on-chip serial ports. if the keyen[1:0] bits are in the enabled state (see section 25.3.2.2 ), the mcu can be unsecured by the backdoor key access sequence described below: 1. follow the command sequence for the verify backdoor access key command as explained in section 25.4.6.11 2. if the verify backdoor access key command is successful, the mcu is unsecured and the sec[1:0] bits in the fsec register are forced to the unsecure state of 10 the verify backdoor access key command is monitored by the memory controller and an illegal key will prohibit future use of the verify backdoor access key command. a reset of the mcu is the only method to re-enable the verify backdoor access key command. the security as de?ed in the flash security byte (0x3_ff0f) is not changed by using the verify backdoor access key command sequence. the backdoor keys stored in addresses 0x3_ff00-0x3_ff07 are unaffected by the verify backdoor access key command sequence. the verify backdoor access key command sequence has no effect on the program and erase protections de?ed in the flash protection register, fprot. after the backdoor keys have been correctly matched, the mcu will be unsecured. after the mcu is unsecured, the sector containing the flash security byte can be erased and the flash security byte can be reprogrammed to the unsecure state, if desired. in the unsecure state, the user has full control of the contents of the backdoor keys by programming addresses 0x3_ff00-0x3_ff07 in the flash con?uration ?ld. 25.5.2 unsecuring the mcu in special single chip mode using bdm a secured mcu can be unsecured in special single chip mode by using the following method to erase the p-flash and eeprom memory: 1. reset the mcu into special single chip mode 2. delay while the bdm executes the erase verify all blocks command write sequence to check if the p-flash and eeprom memories are erased 3. send bdm commands to disable protection in the p-flash and eeprom memory 4. execute the erase all blocks command write sequence to erase the p-flash and eeprom memory. alternatively the unsecure flash command can be executed, if so the steps 5 and 6 below are skeeped. 5. after the ccif ?g sets to indicate that the erase all blocks operation has completed, reset the mcu into special single chip mode 6. delay while the bdm executes the erase verify all blocks command write sequence to verify that the p-flash and eeprom memory are erased if the p-flash and eeprom memory are veri?d as erased, the mcu will be unsecured. all bdm commands will now be enabled and the flash security byte may be programmed to the unsecure state by continuing with the following steps: 7. send bdm commands to execute the program p-flash command write sequence to program the flash security byte to the unsecured state
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 877 8. reset the mcu 25.5.3 mode and security effects on flash command availability the availability of flash module commands depends on the mcu operating mode and security state as shown in table 25-27 . 25.6 initialization on each system reset the ?sh module executes an initialization sequence which establishes initial values for the flash block con?uration parameters, the fprot and eeprot protection registers, and the fopt and fsec registers. the initialization routine reverts to built-in default values that leave the module in a fully protected and secured state if errors are encountered during execution of the reset sequence. if a double bit fault is detected during the reset sequence, both mgstat bits in the fstat register will be set. ccif is cleared throughout the initialization sequence. the flash module holds off all cpu access for a portion of the initialization sequence. flash reads are allowed once the hold is removed. completion of the initialization sequence is marked by setting ccif high which enables user commands. if a reset occurs while any flash command is in progress, that command will be immediately aborted. the state of the word being programmed or the sector/block being erased is not guaranteed.
32 kbyte flash module (s12ftmrg32k1v1) mc9s12g family reference manual, rev.1.23 878 freescale semiconductor
mc9s12g family reference manual, rev.1.23 freescale semiconductor 879 chapter 26 48 kbyte flash module (s12ftmrg48k1v1) 26.1 introduction the ftmrg48k1 module implements the following: 48kbytes of p-flash (program flash) memory 1,536bytes of eeprom memory the flash memory is ideal for single-supply applications allowing for ?ld reprogramming without requiring external high voltage sources for program or erase operations. the flash module includes a memory controller that executes commands to modify flash memory contents. the user interface to the memory controller consists of the indexed flash common command object (fccob) register which is written to with the command, global address, data, and any required command parameters. the memory controller must complete the execution of a command before the fccob register can be written to with a new command. caution a flash word or phrase must be in the erased state before being programmed. cumulative programming of bits within a flash word or phrase is not allowed. table 26-1. revision history revision number revision date sections affected description of changes v01.04 17 jun 2010 26.4.6.1/26-913 26.4.6.2/26-914 26.4.6.3/26-914 26.4.6.14/26-92 4 clarify erase verify commands descriptions related to the bits mgstat[1:0] of the register fstat. v01.05 20 aug 2010 26.4.6.2/26-914 26.4.6.12/26-92 1 26.4.6.13/26-92 3 updated description of the commands rd1blk, mloadu and mloadf rev.1.23 31 jan 2011 26.3.2.9/26-896 updated description of protection on section 26.3.2.9
mc9s12g family reference manual, rev.1.23 freescale semiconductor 880 the flash memory may be read as bytes and aligned words. read access time is one bus cycle for bytes and aligned words. for misaligned words access, the cpu has to perform twice the byte read access command. for flash memory, an erased bit reads 1 and a programmed bit reads 0. it is possible to read from p-flash memory while some commands are executing on eeprom memory. it is not possible to read from eeprom memory while a command is executing on p-flash memory. simultaneous p-flash and eeprom operations are discussed in section 26.4.5 . both p-flash and eeprom memories are implemented with error correction codes (ecc) that can resolve single bit faults and detect double bit faults. for p-flash memory, the ecc implementation requires that programming be done on an aligned 8 byte basis (a flash phrase). since p-flash memory is always read by half-phrase, only one single bit fault in an aligned 4 byte half-phrase containing the byte or word accessed will be corrected. 26.1.1 glossary command write sequence ?an mcu instruction sequence to execute built-in algorithms (including program and erase) on the flash memory. eeprom memory ?the eeprom memory constitutes the nonvolatile memory store for data. eeprom sector ?the eeprom sector is the smallest portion of the eeprom memory that can be erased. the eeprom sector consists of 4 bytes. nvm command mode an nvm mode using the cpu to setup the fccob register to pass parameters required for flash command execution. phrase ?an aligned group of four 16-bit words within the p-flash memory. each phrase includes two sets of aligned double words with each set including 7 ecc bits for single bit fault correction and double bit fault detection within each double word. p-flash memory the p-flash memory constitutes the main nonvolatile memory store for applications. p-flash sector ?the p-flash sector is the smallest portion of the p-flash memory that can be erased. each p-flash sector contains 512 bytes. program ifr ?nonvolatile information register located in the p-flash block that contains the version id, and the program once ?ld. 26.1.2 features 26.1.2.1 p-flash features 48 kbytes of p-flash memory composed of one 48 kbyte flash block divided into 96 sectors of 512 bytes
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 881 single bit fault correction and double bit fault detection within a 32-bit double word during read operations automated program and erase algorithm with verify and generation of ecc parity bits fast sector erase and phrase program operation ability to read the p-flash memory while programming a word in the eeprom memory flexible protection scheme to prevent accidental program or erase of p-flash memory 26.1.2.2 eeprom features 1.5kbytes of eeprom memory composed of one 1.5kbyte flash block divided into 384 sectors of 4 bytes single bit fault correction and double bit fault detection within a word during read operations automated program and erase algorithm with verify and generation of ecc parity bits fast sector erase and word program operation protection scheme to prevent accidental program or erase of eeprom memory ability to program up to four words in a burst sequence 26.1.2.3 other flash module features no external high-voltage power supply required for flash memory program and erase operations interrupt generation on flash command completion and flash error detection security mechanism to prevent unauthorized access to the flash memory
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 882 freescale semiconductor 26.1.3 block diagram the block diagram of the flash module is shown in figure 26-1 . figure 26-1. ftmrg48k1 block diagram 26.2 external signal description the flash module contains no signals that connect off-chip. bus clock divider clock command interrupt request fclk protection security registers flash interface 16bit internal bus sector 0 sector 1 sector 95 12kx39 p-flash error interrupt request cpu 768x22 sector 0 sector 1 sector 383 eeprom memory controller
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 883 26.3 memory map and registers this section describes the memory map and registers for the flash module. read data from unimplemented memory space in the flash module is unde?ed. write access to unimplemented or reserved memory space in the flash module will be ignored by the flash module. caution writing to the flash registers while a flash command is executing (that is indicated when the value of ?g ccif reads as ?? is not allowed. if such action is attempted the write operation will not change the register value. writing to the flash registers is allowed when the flash is not busy executing commands (ccif = 1) and during initialization right after reset, despite the value of ?g ccif in that case (refer to section 26.6 for a complete description of the reset sequence). . 26.3.1 module memory map the s12 architecture places the p-flash memory between global addresses 0x3_4000 and 0x3_ffff as shown in table 26-3 .the p-flash memory map is shown in figure 26-2 . table 26-2. ftmrg memory map global address (in bytes) size (bytes) description 0x0_0000 - 0x0_03ff 1,024 register space 0x0_0400 ?0x0_09ff 1,536 eeprom memory 0x0_0a00 ?0x0_0bff 512 ftmrg reserved area 0x0_4000 ?0x0_7fff 16,284 nvmres 1 =1 : nvm resource area (see figure 26-3 ) 1 see nvmres description in section 26.4.3 0x3_0000 ?0x3_3fff 16,384 ftmrg reserved area 0x3_4000 ?0x3_ffff 49,152 p-flash memory
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 884 freescale semiconductor the fprot register, described in section 26.3.2.9 , can be set to protect regions in the flash memory from accidental program or erase. the flash memory addresses covered by these protectable regions are shown in the p-flash memory map. the higher address region is mainly targeted to hold the boot loader code since it covers the vector space. default protection settings as well as security information that allows the mcu to restrict access to the flash module are stored in the flash con?uration ?ld as described in table 26-4 . table 26-3. p-flash memory addressing global address size (bytes) description 0x3_4000 ?0x3_ffff 48 k p-flash block contains flash con?uration field (see table 26-4 ).
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 885 table 26-4. flash con?uration field global address size (bytes) description 0x3_ff00-0x3_ff07 8 backdoor comparison key refer to section 26.4.6.11, ?erify backdoor access key command , and section 26.5.1, ?nsecuring the mcu using backdoor key access 0x3_ff08-0x3_ff0b 1 1 0x3ff08-0x3_ff0f form a flash phrase and must be programmed in a single command write sequence. each byte in the 0x3_ff08 - 0x3_ff0b reserved ?ld should be programmed to 0xff. 4 reserved 0x3_ff0c 1 1 p-flash protection byte . refer to section 26.3.2.9, ?-flash protection register (fprot) 0x3_ff0d 1 1 eeprom protection byte . refer to section 26.3.2.10, ?eprom protection register (eeprot) 0x3_ff0e 1 1 flash nonvolatile byte refer to section 26.3.2.16, ?lash option register (fopt) 0x3_ff0f 1 1 flash security byte refer to section 26.3.2.2, ?lash security register (fsec)
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 886 freescale semiconductor figure 26-2. p-flash memory map table 26-5. program ifr fields global address size (bytes) field description 0x0_4000 ?0x0_4007 8 reserved 0x0_4008 ?0x0_40b5 174 reserved 0x0_40b6 ?0x0_40b7 2 version id 1 1 used to track ?mware patch versions, see section 26.4.2 0x0_40b8 ?0x0_40bf 8 reserved 0x0_40c0 ?0x0_40ff 64 program once field refer to section 26.4.6.6, ?rogram once command flash con?uration field 0x3_c000 flash protected/unprotected lower region 1, 2, 4, 8 kbytes 0x3_8000 0x3_9000 0x3_8400 0x3_8800 0x3_a000 p-flash end = 0x3_ffff 0x3_f800 0x3_f000 0x3_e000 flash protected/unprotected higher region 2, 4, 8, 16 kbytes flash protected/unprotected region 8 kbytes (up to 29 kbytes) 16 bytes (0x3_ff00 - 0x3_ff0f) flash protected/unprotected region 16 kbytes p-flash start = 0x3_4000 protection protection protection movable end fixed end fixed end
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 887 figure 26-3. memory controller resource memory map (nvmres=1) 26.3.2 register descriptions the flash module contains a set of 20 control and status registers located between flash module base + 0x0000 and 0x0013. in the case of the writable registers, the write accesses are forbidden during fash command execution (for more detail, see caution note in section 26.3 ). table 26-6. memory controller resource fields (nvmres 1 =1) 1 nvmres - see section 26.4.3 for nvmres (nvm resource) detail. global address size (bytes) description 0x0_4000 ?0x040ff 256 p-flash ifr (see table 26-5 ) 0x0_4100 ?0x0_41ff 256 reserved. 0x0_4200 ?0x0_57ff reserved 0x0_5800 ?0x0_59ff 512 reserved 0x0_5a00 ?0x0_5fff 1,536 reserved 0x0_6000 ?0x0_6bff 3,072 reserved 0x0_6c00 ?0x0_7fff 5,120 reserved p-flash ifr 1 kbyte (nvmres=1) 0x0_4000 ram end = 0x0_59ff ram start = 0x0_5800 reserved 5120 bytes reserved 4608 bytes 0x0_6c00 0x0_7fff 0x0_4400 reserved 5k bytes reserved 512 bytes
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 888 freescale semiconductor a summary of the flash module registers is given in figure 26-4 with detailed descriptions in the following subsections. address & name 76543210 0x0000 fclkdiv r fdivld fdivlck fdiv5 fdiv4 fdiv3 fdiv2 fdiv1 fdiv0 w 0x0001 fsec r keyen1 keyen0 rnv5 rnv4 rnv3 rnv2 sec1 sec0 w 0x0002 fccobix r0 0 0 0 0 ccobix2 ccobix1 ccobix0 w 0x0003 frsv0 r00000000 w 0x0004 fcnfg r ccie 00 ignsf 00 fdfd fsfd w 0x0005 fercnfg r0 0 0 0 0 0 dfdie sfdie w 0x0006 fstat r ccif 0 accerr fpviol mgbusy rsvd mgstat1 mgstat0 w 0x0007 ferstat r0 0 0 0 0 0 dfdif sfdif w 0x0008 fprot r fpopen rnv6 fphdis fphs1 fphs0 fpldis fpls1 fpls0 w 0x0009 eeprot r dpopen 0 dps5 dps4 dps3 dps2 dps1 dps0 w 0x000a fccobhi r ccob15 ccob14 ccob13 ccob12 ccob11 ccob10 ccob9 ccob8 w 0x000b fccoblo r ccob7 ccob6 ccob5 ccob4 ccob3 ccob2 ccob1 ccob0 w 0x000c frsv1 r00000000 w figure 26-4. ftmrg48k1 register summary
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 889 26.3.2.1 flash clock divider register (fclkdiv) the fclkdiv register is used to control timed events in program and erase algorithms. all bits in the fclkdiv register are readable, bit 7 is not writable, bit 6 is write-once-hi and controls the writability of the fdiv ?ld in normal mode. in special mode, bits 6-0 are writable any number of times but bit 7 remains unwritable. 0x000d frsv2 r00000000 w 0x000e frsv3 r00000000 w 0x000f frsv4 r00000000 w 0x0010 fopt r nv7 nv6 nv5 nv4 nv3 nv2 nv1 nv0 w 0x0011 frsv5 r00000000 w 0x0012 frsv6 r00000000 w 0x0013 frsv7 r00000000 w = unimplemented or reserved offset module base + 0x0000 76543210 r fdivld fdivlck fdiv[5:0] w reset 00000000 = unimplemented or reserved figure 26-5. flash clock divider register (fclkdiv) address & name 76543210 figure 26-4. ftmrg48k1 register summary (continued)
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 890 freescale semiconductor caution the fclkdiv register should never be written while a flash command is executing (ccif=0). table 26-7. fclkdiv field descriptions field description 7 fdivld clock divider loaded 0 fclkdiv register has not been written since the last reset 1 fclkdiv register has been written since the last reset 6 fdivlck clock divider locked 0 fdiv ?ld is open for writing 1 fdiv value is locked and cannot be changed. once the lock bit is set high, only reset can clear this bit and restore writability to the fdiv ?ld in normal mode. 5? fdiv[5:0] clock divider bits fdiv[5:0] must be set to effectively divide busclk down to 1 mhz to control timed events during flash program and erase algorithms. table 26-8 shows recommended values for fdiv[5:0] based on the busclk frequency. please refer to section 26.4.4, ?lash command operations , for more information. table 26-8. fdiv values for various busclk frequencies busclk frequency (mhz) fdiv[5:0] busclk frequency (mhz) fdiv[5:0] min 1 1 busclk is greater than this value. max 2 2 busclk is less than or equal to this value. min 1 max 2 1.0 1.6 0x00 16.6 17.6 0x10 1.6 2.6 0x01 17.6 18.6 0x11 2.6 3.6 0x02 18.6 19.6 0x12 3.6 4.6 0x03 19.6 20.6 0x13 4.6 5.6 0x04 20.6 21.6 0x14 5.6 6.6 0x05 21.6 22.6 0x15 6.6 7.6 0x06 22.6 23.6 0x16 7.6 8.6 0x07 23.6 24.6 0x17 8.6 9.6 0x08 24.6 25.6 0x18 9.6 10.6 0x09 10.6 11.6 0x0a 11.6 12.6 0x0b 12.6 13.6 0x0c 13.6 14.6 0x0d 14.6 15.6 0x0e 15.6 16.6 0x0f
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 891 26.3.2.2 flash security register (fsec) the fsec register holds all bits associated with the security of the mcu and flash module. all bits in the fsec register are readable but not writable. during the reset sequence, the fsec register is loaded with the contents of the flash security byte in the flash con?uration ?ld at global address 0x3_ff0f located in p-flash memory (see table 26-4 ) as indicated by reset condition f in figure 26-6 . if a double bit fault is detected while reading the p-flash phrase containing the flash security byte during the reset sequence, all bits in the fsec register will be set to leave the flash module in a secured state with backdoor key access disabled. offset module base + 0x0001 76543210 r keyen[1:0] rnv[5:2] sec[1:0] w reset f 1 1 loaded from ifr flash con?uration ?ld, during reset sequence. f 1 f 1 f 1 f 1 f 1 f 1 f 1 = unimplemented or reserved figure 26-6. flash security register (fsec) table 26-9. fsec field descriptions field description 7? keyen[1:0] backdoor key security enable bits the keyen[1:0] bits de?e the enabling of backdoor key access to the flash module as shown in table 26-10 . 5? rnv[5:2] reserved nonvolatile bits ?the rnv bits should remain in the erased state for future enhancements. 1? sec[1:0] flash security bits ?the sec[1:0] bits de?e the security state of the mcu as shown in table 26-11 . if the flash module is unsecured using backdoor key access, the sec bits are forced to 10. table 26-10. flash keyen states keyen[1:0] status of backdoor key access 00 disabled 01 disabled 1 1 preferred keyen state to disable backdoor key access. 10 enabled 11 disabled
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 892 freescale semiconductor the security function in the flash module is described in section 26.5 . 26.3.2.3 flash ccob index register (fccobix) the fccobix register is used to index the fccob register for flash memory operations. ccobix bits are readable and writable while remaining bits read 0 and are not writable. 26.3.2.4 flash reserved0 register (frsv0) this flash register is reserved for factory testing. all bits in the frsv0 register read 0 and are not writable. table 26-11. flash security states sec[1:0] status of security 00 secured 01 secured 1 1 preferred sec state to set mcu to secured state. 10 unsecured 11 secured offset module base + 0x0002 76543210 r00000 ccobix[2:0] w reset 00000000 = unimplemented or reserved figure 26-7. fccob index register (fccobix) table 26-12. fccobix field descriptions field description 2? ccobix[1:0] common command register index the ccobix bits are used to select which word of the fccob register array is being read or written to. see 26.3.2.11 flash common command object register (fccob), for more details. offset module base + 0x000c 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 26-8. flash reserved0 register (frsv0)
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 893 26.3.2.5 flash con?uration register (fcnfg) the fcnfg register enables the flash command complete interrupt and forces ecc faults on flash array read access from the cpu. ccie, ignsf, fdfd, and fsfd bits are readable and writable while remaining bits read 0 and are not writable. 26.3.2.6 flash error con?uration register (fercnfg) the fercnfg register enables the flash error interrupts for the ferstat ?gs. offset module base + 0x0004 76543210 r ccie 00 ignsf 00 fdfd fsfd w reset 00000000 = unimplemented or reserved figure 26-9. flash con?uration register (fcnfg) table 26-13. fcnfg field descriptions field description 7 ccie command complete interrupt enable ?the ccie bit controls interrupt generation when a flash command has completed. 0 command complete interrupt disabled 1 an interrupt will be requested whenever the ccif ?g in the fstat register is set (see section 26.3.2.7 ) 4 ignsf ignore single bit fault ?the ignsf controls single bit fault reporting in the ferstat register (see section 26.3.2.8 ). 0 all single bit faults detected during array reads are reported 1 single bit faults detected during array reads are not reported and the single bit fault interrupt will not be generated 1 fdfd force double bit fault detect the fdfd bit allows the user to simulate a double bit fault during flash array read operations and check the associated interrupt routine. the fdfd bit is cleared by writing a 0 to fdfd. 0 flash array read operations will set the dfdif ?g in the ferstat register only if a double bit fault is detected 1 any flash array read operation will force the dfdif ?g in the ferstat register to be set (see section 26.3.2.7 ) and an interrupt will be generated as long as the dfdie interrupt enable in the fercnfg register is set (see section 26.3.2.6 ) 0 fsfd force single bit fault detect the fsfd bit allows the user to simulate a single bit fault during flash array read operations and check the associated interrupt routine. the fsfd bit is cleared by writing a 0 to fsfd. 0 flash array read operations will set the sfdif ?g in the ferstat register only if a single bit fault is detected 1 flash array read operation will force the sfdif ?g in the ferstat register to be set (see section 26.3.2.7 ) and an interrupt will be generated as long as the sfdie interrupt enable in the fercnfg register is set (see section 26.3.2.6 )
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 894 freescale semiconductor all assigned bits in the fercnfg register are readable and writable. 26.3.2.7 flash status register (fstat) the fstat register reports the operational status of the flash module. ccif, accerr, and fpviol bits are readable and writable, mgbusy and mgstat bits are readable but not writable, while remaining bits read 0 and are not writable. offset module base + 0x0005 76543210 r000000 dfdie sfdie w reset 00000000 = unimplemented or reserved figure 26-10. flash error con?uration register (fercnfg) table 26-14. fercnfg field descriptions field description 1 dfdie double bit fault detect interrupt enable the dfdie bit controls interrupt generation when a double bit fault is detected during a flash block read operation. 0 dfdif interrupt disabled 1 an interrupt will be requested whenever the dfdif ?g is set (see section 26.3.2.8 ) 0 sfdie single bit fault detect interrupt enable the sfdie bit controls interrupt generation when a single bit fault is detected during a flash block read operation. 0 sfdif interrupt disabled whenever the sfdif ?g is set (see section 26.3.2.8 ) 1 an interrupt will be requested whenever the sfdif ?g is set (see section 26.3.2.8 ) offset module base + 0x0006 76543210 r ccif 0 accerr fpviol mgbusy rsvd mgstat[1:0] w reset 1000000 1 1 reset value can deviate from the value shown if a double bit fault is detected during the reset sequence (see section 26.6 ). 0 1 = unimplemented or reserved figure 26-11. flash status register (fstat)
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 895 26.3.2.8 flash error status register (ferstat) the ferstat register re?cts the error status of internal flash operations. all ?gs in the ferstat register are readable and only writable to clear the ?g. table 26-15. fstat field descriptions field description 7 ccif command complete interrupt flag ?the ccif ?g indicates that a flash command has completed. the ccif ?g is cleared by writing a 1 to ccif to launch a command and ccif will stay low until command completion or command violation. 0 flash command in progress 1 flash command has completed 5 accerr flash access error flag ?the accerr bit indicates an illegal access has occurred to the flash memory caused by either a violation of the command write sequence (see section 26.4.4.2 ) or issuing an illegal flash command. while accerr is set, the ccif ?g cannot be cleared to launch a command. the accerr bit is cleared by writing a 1 to accerr. writing a 0 to the accerr bit has no effect on accerr. 0 no access error detected 1 access error detected 4 fpviol flash protection violation flag ?he fpviol bit indicates an attempt was made to program or erase an address in a protected area of p-flash or eeprom memory during a command write sequence. the fpviol bit is cleared by writing a 1 to fpviol. writing a 0 to the fpviol bit has no effect on fpviol. while fpviol is set, it is not possible to launch a command or start a command write sequence. 0 no protection violation detected 1 protection violation detected 3 mgbusy memory controller busy flag ?the mgbusy ?g re?cts the active state of the memory controller . 0 memory controller is idle 1 memory controller is busy executing a flash command (ccif = 0) 2 rsvd reserved bit ?this bit is reserved and always reads 0 . 1? mgstat[1:0] memory controller command completion status flag one or more mgstat ?g bits are set if an error is detected during execution of a flash command or during the flash reset sequence. see section 26.4.6, ?lash command description , and section 26.6, ?nitialization ?for details. offset module base + 0x0007 76543210 r000000 dfdif sfdif w reset 00000000 = unimplemented or reserved figure 26-12. flash error status register (ferstat)
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 896 freescale semiconductor 26.3.2.9 p-flash protection register (fprot) the fprot register de?es which p-flash sectors are protected against program and erase operations. the (unreserved) bits of the fprot register are writable with the restriction that the size of the protected region can only be increased (see section 26.3.2.9.1, ?-flash protection restrictions , and table 26-21 ). during the reset sequence, the fprot register is loaded with the contents of the p-flash protection byte in the flash con?uration ?ld at global address 0x3_ff0c located in p-flash memory (see table 26-4 ) as indicated by reset condition ??in figure 26-13 . to change the p-flash protection that will be loaded during the reset sequence, the upper sector of the p-flash memory must be unprotected, then the p-flash protection byte must be reprogrammed. if a double bit fault is detected while reading the p-flash phrase containing the p-flash protection byte during the reset sequence, the fpopen bit will be cleared and remaining bits in the fprot register will be set to leave the p-flash memory fully protected. table 26-16. ferstat field descriptions field description 1 dfdif double bit fault detect interrupt flag ?the setting of the dfdif ?g indicates that a double bit fault was detected in the stored parity and data bits during a flash array read operation or that a flash array read operation returning invalid data was attempted on a flash block that was under a flash command operation. 1 the dfdif ?g is cleared by writing a 1 to dfdif. writing a 0 to dfdif has no effect on dfdif. 2 0 no double bit fault detected 1 double bit fault detected or a flash array read operation returning invalid data was attempted while command running 1 the single bit fault and double bit fault ?gs are mutually exclusive for parity errors (an ecc fault occurrence can be either single fault or double fault but never both). a simultaneous access collision (flash array read operation returning invalid data attempted while command running) is indicated when both sfdif and dfdif ?gs are high. 2 there is a one cycle delay in storing the ecc dfdif and sfdif fault ?gs in this register. at least one nop is required after a ?sh memory read before checking ferstat for the occurrence of ecc errors. 0 sfdif single bit fault detect interrupt flag ?with the ignsf bit in the fcnfg register clear, the sfdif ?g indicates that a single bit fault was detected in the stored parity and data bits during a flash array read operation or that a flash array read operation returning invalid data was attempted on a flash block that was under a flash command operation. 1 the sfdif ?g is cleared by writing a 1 to sfdif. writing a 0 to sfdif has no effect on sfdif. 0 no single bit fault detected 1 single bit fault detected and corrected or a flash array read operation returning invalid data was attempted while command running offset module base + 0x0008 76543210 r fpopen rnv6 fphdis fphs[1:0] fpldis fpls[1:0] w reset f 1 1 loaded from ifr flash con?uration ?ld, during reset sequence. f 1 f 1 f 1 f 1 f 1 f 1 f 1 = unimplemented or reserved figure 26-13. flash protection register (fprot)
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 897 trying to alter data in any protected area in the p-flash memory will result in a protection violation error and the fpviol bit will be set in the fstat register. the block erase of a p-flash block is not possible if any of the p-flash sectors contained in the same p-flash block are protected. table 26-17. fprot field descriptions field description 7 fpopen flash protection operation enable ?the fpopen bit determines the protection function for program or erase operations as shown in table 26-18 for the p-flash block. 0 when fpopen is clear, the fphdis and fpldis bits de?e unprotected address ranges as speci?d by the corresponding fphs and fpls bits 1 when fpopen is set, the fphdis and fpldis bits enable protection for the address range speci?d by the corresponding fphs and fpls bits 6 rnv[6] reserved nonvolatile bit ?the rnv bit should remain in the erased state for future enhancements. 5 fphdis flash protection higher address range disable ?the fphdis bit determines whether there is a protected/unprotected area in a speci? region of the p-flash memory ending with global address 0x3_ffff. 0 protection/unprotection enabled 1 protection/unprotection disabled 4? fphs[1:0] flash protection higher address size the fphs bits determine the size of the protected/unprotected area in p-flash memory as shown in table 26-19 . the fphs bits can only be written to while the fphdis bit is set. 2 fpldis flash protection lower address range disable ?the fpldis bit determines whether there is a protected/unprotected area in a speci? region of the p-flash memory beginning with global address 0x3_8000. 0 protection/unprotection enabled 1 protection/unprotection disabled 1? fpls[1:0] flash protection lower address size the fpls bits determine the size of the protected/unprotected area in p-flash memory as shown in table 26-20 . the fpls bits can only be written to while the fpldis bit is set. table 26-18. p-flash protection function fpopen fphdis fpldis function 1 1 for range sizes, refer to table 26-19 and table 26-20 . 1 1 1 no p-flash protection 1 1 0 protected low range 1 0 1 protected high range 1 0 0 protected high and low ranges 0 1 1 full p-flash memory protected 0 1 0 unprotected low range 0 0 1 unprotected high range 0 0 0 unprotected high and low ranges
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 898 freescale semiconductor all possible p-flash protection scenarios are shown in figure 26-14 . although the protection scheme is loaded from the flash memory at global address 0x3_ff0c during the reset sequence, it can be changed by the user. the p-flash protection scheme can be used by applications requiring reprogramming in single chip mode while providing as much protection as possible if reprogramming is not required. table 26-19. p-flash protection higher address range fphs[1:0] global address range protected size 00 0x3_f800?x3_ffff 2 kbytes 01 0x3_f000?x3_ffff 4 kbytes 10 0x3_e000?x3_ffff 8 kbytes 11 0x3_c000?x3_ffff 16 kbytes table 26-20. p-flash protection lower address range fpls[1:0] global address range protected size 00 0x3_8000?x3_83ff 1 kbyte 01 0x3_8000?x3_87ff 2 kbytes 10 0x3_8000?x3_8fff 4 kbytes 11 0x3_8000?x3_9fff 8 kbytes
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 899 figure 26-14. p-flash protection scenarios 7 6 5 4 fphs[1:0] fpls[1:0] 3 2 1 0 fphs[1:0] fpls[1:0] fphdis = 1 fpldis = 1 fphdis = 1 fpldis = 0 fphdis = 0 fpldis = 1 fphdis = 0 fpldis = 0 scenario scenario unprotected region protected region with size protected region protected region with size defined by fpls defined by fphs not defined by fpls, fphs 0x3_8000 0x3_ffff 0x3_8000 0x3_ffff flash start flash start fpopen = 1 fpopen = 0
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 900 freescale semiconductor 26.3.2.9.1 p-flash protection restrictions the general guideline is that p-flash protection can only be added and not removed. table 26-21 speci?s all valid transitions between p-flash protection scenarios. any attempt to write an invalid scenario to the fprot register will be ignored. the contents of the fprot register re?ct the active protection scenario. see the fphs and fpls bit descriptions for additional restrictions. 26.3.2.10 eeprom protection register (eeprot) the eeprot register de?es which eeprom sectors are protected against program and erase operations. the (unreserved) bits of the eeprot register are writable with the restriction that protection can be added but not removed. writes must increase the dps value and the dpopen bit can only be written from 1 (protection disabled) to 0 (protection enabled). if the dpopen bit is set, the state of the dps bits is irrelevant. table 26-21. p-flash protection scenario transitions from protection scenario to protection scenario 1 1 allowed transitions marked with x, see figure 26-14 for a de?ition of the scenarios. 01234567 0 xxxx 1 xx 2 xx 3 x 4 xx 5 xxxx 6 xxxx 7 xxxxxxxx offset module base + 0x0009 76543210 r dpopen 0 dps[5:0] w reset f 1 1 loaded from ifr flash con?uration ?ld, during reset sequence. 0f 1 f 1 f 1 f 1 f 1 f 1 = unimplemented or reserved figure 26-15. eeprom protection register (eeprot)
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 901 during the reset sequence, ?lds dpopen and dps of the eeprot register are loaded with the contents of the eeprom protection byte in the flash configuration field at global address 0x3_ff0d located in p-flash memory (see table 26-4 ) as indicated by reset condition f in table 26-23 . to change the eeprom protection that will be loaded during the reset sequence, the p-flash sector containing the eeprom protection byte must be unprotected, then the eeprom protection byte must be programmed. if a double bit fault is detected while reading the p-flash phrase containing the eeprom protection byte during the reset sequence, the dpopen bit will be cleared and dps bits will be set to leave the eeprom memory fully protected. trying to alter data in any protected area in the eeprom memory will result in a protection violation error and the fpviol bit will be set in the fstat register. block erase of the eeprom memory is not possible if any of the eeprom sectors are protected. table 26-22. eeprot field descriptions field description 7 dpopen eeprom protection control 0 enables eeprom memory protection from program and erase with protected address range de?ed by dps bits 1 disables eeprom memory protection from program and erase 5? dps[5:0] eeprom protection size ?the dps[5:0] bits determine the size of the protected area in the eeprom memory as shown in table 26-23 . table 26-23. eeprom protection address range dps[5:0] global address range protected size 000000 0x0_0400 ?0x0_041f 32 bytes 000001 0x0_0400 ?0x0_043f 64 bytes 000010 0x0_0400 ?0x0_045f 96 bytes 000011 0x0_0400 ?0x0_047f 128 bytes 000100 0x0_0400 ?0x0_049f 160 bytes 000101 0x0_0400 ?0x0_04bf 192 bytes the protection size goes on enlarging in step of 32 bytes, for each dps value increasing of one. . . . 101111 - to - 111111 0x0_0400 ?0x0_09ff 1,536 bytes
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 902 freescale semiconductor 26.3.2.11 flash common command object register (fccob) the fccob is an array of six words addressed via the ccobix index found in the fccobix register. byte wide reads and writes are allowed to the fccob register. 26.3.2.11.1 fccob - nvm command mode nvm command mode uses the indexed fccob register to provide a command code and its relevant parameters to the memory controller. the user ?st sets up all required fccob ?lds and then initiates the commands execution by writing a 1 to the ccif bit in the fstat register (a 1 written by the user clears the ccif command completion ?g to 0). when the user clears the ccif bit in the fstat register all fccob parameter ?lds are locked and cannot be changed by the user until the command completes (as evidenced by the memory controller returning ccif to 1). some commands return information to the fccob register array. the generic format for the fccob parameter ?lds in nvm command mode is shown in table 26-24 . the return values are available for reading after the ccif ?g in the fstat register has been returned to 1 by the memory controller. writes to the unimplemented parameter ?lds (ccobix = 110 and ccobix = 111) are ignored with reads from these ?lds returning 0x0000. table 26-24 shows the generic flash command format. the high byte of the ?st word in the ccob array contains the command code, followed by the parameters for this speci? flash command. for details on the fccob settings required by each command, see the flash command descriptions in section 26.4.6 . offset module base + 0x000a 76543210 r ccob[15:8] w reset 00000000 figure 26-16. flash common command object high register (fccobhi) offset module base + 0x000b 76543210 r ccob[7:0] w reset 00000000 figure 26-17. flash common command object low register (fccoblo) table 26-24. fccob - nvm command mode (typical usage) ccobix[2:0] byte fccob parameter fields (nvm command mode) 000 hi fcmd[7:0] de?ing flash command lo 6?0, global address [17:16] 001 hi global address [15:8] lo global address [7:0]
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 903 26.3.2.12 flash reserved1 register (frsv1) this flash register is reserved for factory testing. all bits in the frsv1 register read 0 and are not writable. 26.3.2.13 flash reserved2 register (frsv2) this flash register is reserved for factory testing. all bits in the frsv2 register read 0 and are not writable. 26.3.2.14 flash reserved3 register (frsv3) this flash register is reserved for factory testing. 010 hi data 0 [15:8] lo data 0 [7:0] 011 hi data 1 [15:8] lo data 1 [7:0] 100 hi data 2 [15:8] lo data 2 [7:0] 101 hi data 3 [15:8] lo data 3 [7:0] offset module base + 0x000c 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 26-18. flash reserved1 register (frsv1) offset module base + 0x000d 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 26-19. flash reserved2 register (frsv2) table 26-24. fccob - nvm command mode (typical usage) ccobix[2:0] byte fccob parameter fields (nvm command mode)
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 904 freescale semiconductor all bits in the frsv3 register read 0 and are not writable. 26.3.2.15 flash reserved4 register (frsv4) this flash register is reserved for factory testing. all bits in the frsv4 register read 0 and are not writable. 26.3.2.16 flash option register (fopt) the fopt register is the flash option register. all bits in the fopt register are readable but are not writable. during the reset sequence, the fopt register is loaded from the flash nonvolatile byte in the flash con?uration ?ld at global address 0x3_ff0e located in p-flash memory (see table 26-4 ) as indicated by reset condition f in figure 26-22 . if a double bit fault is detected while reading the p-flash phrase containing the flash nonvolatile byte during the reset sequence, all bits in the fopt register will be set. offset module base + 0x000e 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 26-20. flash reserved3 register (frsv3) offset module base + 0x000f 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 26-21. flash reserved4 register (frsv4) offset module base + 0x0010 76543210 r nv[7:0] w reset f 1 1 loaded from ifr flash con?uration ?ld, during reset sequence. f 1 f 1 f 1 f 1 f 1 f 1 f 1 = unimplemented or reserved figure 26-22. flash option register (fopt)
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 905 26.3.2.17 flash reserved5 register (frsv5) this flash register is reserved for factory testing. all bits in the frsv5 register read 0 and are not writable. 26.3.2.18 flash reserved6 register (frsv6) this flash register is reserved for factory testing. all bits in the frsv6 register read 0 and are not writable. 26.3.2.19 flash reserved7 register (frsv7) this flash register is reserved for factory testing. table 26-25. fopt field descriptions field description 7? nv[7:0] nonvolatile bits the nv[7:0] bits are available as nonvolatile bits. refer to the device user guide for proper use of the nv bits. offset module base + 0x0011 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 26-23. flash reserved5 register (frsv5) offset module base + 0x0012 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 26-24. flash reserved6 register (frsv6)
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 906 freescale semiconductor all bits in the frsv7 register read 0 and are not writable. 26.4 functional description 26.4.1 modes of operation the ftmrg48k1 module provides the modes of operation normal and special . the operating mode is determined by module-level inputs and affects the fclkdiv, fcnfg, and eeprot registers (see table 26-27 ). 26.4.2 ifr version id word the version id word is stored in the ifr at address 0x0_40b6. the contents of the word are de?ed in table 26-26 . vernum: version number. the ?st version is number 0b_0001 with both 0b_0000 and 0b_1111 meaning ?one? offset module base + 0x0013 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 26-25. flash reserved7 register (frsv7) table 26-26. ifr version id fields [15:4] [3:0] reserved vernum
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 907 26.4.3 internal nvm resource (nvmres) ifr is an internal nvm resource readable by cpu , when nvmres is active. the ifr ?lds are shown in table 26-5 . the nvmres global address map is shown in table 26-6 . 26.4.4 flash command operations flash command operations are used to modify flash memory contents. the next sections describe: how to write the fclkdiv register that is used to generate a time base (fclk) derived from busclk for flash program and erase command operations the command write sequence used to set flash command parameters and launch execution valid flash commands available for execution, according to mcu functional mode and mcu security state. 26.4.4.1 writing the fclkdiv register prior to issuing any flash program or erase command after a reset, the user is required to write the fclkdiv register to divide busclk down to a target fclk of 1 mhz. table 26-8 shows recommended values for the fdiv ?ld based on busclk frequency. note programming or erasing the flash memory cannot be performed if the bus clock runs at less than 0.8 mhz. setting fdiv too high can destroy the flash memory due to overstress. setting fdiv too low can result in incomplete programming or erasure of the flash memory cells. when the fclkdiv register is written, the fdivld bit is set automatically. if the fdivld bit is 0, the fclkdiv register has not been written since the last reset. if the fclkdiv register has not been written, any flash program or erase command loaded during a command write sequence will not execute and the accerr bit in the fstat register will set. 26.4.4.2 command write sequence the memory controller will launch all valid flash commands entered using a command write sequence. before launching a command, the accerr and fpviol bits in the fstat register must be clear (see section 26.3.2.7 ) and the ccif ?g should be tested to determine the status of the current command write sequence. if ccif is 0, the previous command write sequence is still active, a new command write sequence cannot be started, and all writes to the fccob register are ignored.
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 908 freescale semiconductor 26.4.4.2.1 de?e fccob contents the fccob parameter ?lds must be loaded with all required parameters for the flash command being executed. access to the fccob parameter ?lds is controlled via the ccobix bits in the fccobix register (see section 26.3.2.3 ). the contents of the fccob parameter ?lds are transferred to the memory controller when the user clears the ccif command completion ?g in the fstat register (writing 1 clears the ccif to 0). the ccif ?g will remain clear until the flash command has completed. upon completion, the memory controller will return ccif to 1 and the fccob register will be used to communicate any results. the ?w for a generic command write sequence is shown in figure 26-26 .
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 909 figure 26-26. generic flash command write sequence flowchart write to fccobix register write: fstat register (to launch command) clear ccif 0x80 clear accerr/fpviol 0x30 write: fstat register yes no access error and protection violation read: fstat register start check fccob accerr/ fpviol set? exit write: fclkdiv register read: fclkdiv register yes no fdiv correct? no bit polling for command completion check yes ccif set? to identify speci? command parameter to load. write to fccob register to load required command parameter. yes no more parameters? availability check results from previous command note: fclkdiv must be set after each reset read: fstat register no yes ccif set? no yes ccif set? clock divider value check read: fstat register
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 910 freescale semiconductor 26.4.4.3 valid flash module commands table 26-27 present the valid flash commands, as enabled by the combination of the functional mcu mode (normal singlechip ns, special singlechip ss) with the mcu security state (unsecured, secured). special singlechip mode is selected by input mmc_ss_mode_ts2 asserted. mcu secured state is selected by input mmc_secure input asserted. + 26.4.4.4 p-flash commands table 26-28 summarizes the valid p-flash commands along with the effects of the commands on the p-flash block and other resources within the flash module. table 26-27. flash commands by mode and security state fcmd command unsecured secured ns 1 1 unsecured normal single chip mode ss 2 2 unsecured special single chip mode. ns 3 3 secured normal single chip mode. ss 4 4 secured special single chip mode. 0x01 erase verify all blocks ???? 0x02 erase verify block ???? 0x03 erase verify p-flash section ??? 0x04 read once ??? 0x06 program p-flash ??? 0x07 program once ??? 0x08 erase all blocks ?? 0x09 erase flash block ??? 0x0a erase p-flash sector ??? 0x0b unsecure flash ?? 0x0c verify backdoor access key ?? 0x0d set user margin level ??? 0x0e set field margin level ? 0x10 erase verify eeprom section ??? 0x11 program eeprom ??? 0x12 erase eeprom sector ??? table 26-28. p-flash commands fcmd command function on p-flash memory 0x01 erase verify all blocks verify that all p-flash (and eeprom) blocks are erased.
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 911 26.4.4.5 eeprom commands table 26-29 summarizes the valid eeprom commands along with the effects of the commands on the eeprom block. 0x02 erase verify block verify that a p-flash block is erased. 0x03 erase verify p-flash section verify that a given number of words starting at the address provided are erased. 0x04 read once read a dedicated 64 byte ?ld in the nonvolatile information register in p-flash block that was previously programmed using the program once command. 0x06 program p-flash program a phrase in a p-flash block. 0x07 program once program a dedicated 64 byte ?ld in the nonvolatile information register in p-flash block that is allowed to be programmed only once. 0x08 erase all blocks erase all p-flash (and eeprom) blocks. an erase of all flash blocks is only possible when the fpldis, fphdis, and fpopen bits in the fprot register and the dpopen bit in the eeprot register are set prior to launching the command. 0x09 erase flash block erase a p-flash (or eeprom) block. an erase of the full p-flash block is only possible when fpldis, fphdis and fpopen bits in the fprot register are set prior to launching the command. 0x0a erase p-flash sector erase all bytes in a p-flash sector. 0x0b unsecure flash supports a method of releasing mcu security by erasing all p-flash (and eeprom) blocks and verifying that all p-flash (and eeprom) blocks are erased. 0x0c verify backdoor access key supports a method of releasing mcu security by verifying a set of security keys. 0x0d set user margin level speci?s a user margin read level for all p-flash blocks. 0x0e set field margin level speci?s a ?ld margin read level for all p-flash blocks (special modes only). table 26-29. eeprom commands fcmd command function on eeprom memory 0x01 erase verify all blocks verify that all eeprom (and p-flash) blocks are erased. 0x02 erase verify block verify that the eeprom block is erased. table 26-28. p-flash commands fcmd command function on p-flash memory
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 912 freescale semiconductor 26.4.5 allowed simultaneous p-flash and eeprom operations only the operations marked ?k?in table 26-30 are permitted to be run simultaneously on the program flash and eeprom blocks. some operations cannot be executed simultaneously because certain hardware resources are shared by the two memories. the priority has been placed on permitting program flash reads while program and erase operations execute on the eeprom, providing read (p-flash) while write (eeprom) functionality. 0x08 erase all blocks erase all eeprom (and p-flash) blocks. an erase of all flash blocks is only possible when the fpldis, fphdis, and fpopen bits in the fprot register and the dpopen bit in the eeprot register are set prior to launching the command. 0x09 erase flash block erase a eeprom (or p-flash) block. an erase of the full eeprom block is only possible when dpopen bit in the eeprot register is set prior to launching the command. 0x0b unsecure flash supports a method of releasing mcu security by erasing all eeprom (and p-flash) blocks and verifying that all eeprom (and p-flash) blocks are erased. 0x0d set user margin level speci?s a user margin read level for the eeprom block. 0x0e set field margin level speci?s a ?ld margin read level for the eeprom block (special modes only). 0x10 erase verify eeprom section verify that a given number of words starting at the address provided are erased. 0x11 program eeprom program up to four words in the eeprom block. 0x12 erase eeprom sector erase all bytes in a sector of the eeprom block. table 26-30. allowed p-flash and eeprom simultaneous operations eeprom program flash read margin read 1 program sector erase mass erase 2 read ok ok ok margin read 1 1 a ?argin read?is any read after executing the margin setting commands ?et user margin level?or ?et field margin level?with anything but the ?ormal level speci?d. see the note on margin settings in section 26.4.6.12 and section 26.4.6.13 . program sector erase mass erase 2 2 the ?ass erase?operations are commands ?rase all blocks?and ?rase flash block ok table 26-29. eeprom commands fcmd command function on eeprom memory
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 913 26.4.6 flash command description this section provides details of all available flash commands launched by a command write sequence. the accerr bit in the fstat register will be set during the command write sequence if any of the following illegal steps are performed, causing the command not to be processed by the memory controller: starting any command write sequence that programs or erases flash memory before initializing the fclkdiv register writing an invalid command as part of the command write sequence for additional possible errors, refer to the error handling table provided for each command if a flash block is read during execution of an algorithm (ccif = 0) on that same block, the read operation will return invalid data if both ?gs sfdif and dfdif are set. if the sfdif or dfdif ?gs were not previously set when the invalid read operation occurred, both the sfdif and dfdif ?gs will be set. if the accerr or fpviol bits are set in the fstat register, the user must clear these bits before starting any command write sequence (see section 26.3.2.7 ). caution a flash word or phrase must be in the erased state before being programmed. cumulative programming of bits within a flash word or phrase is not allowed. 26.4.6.1 erase verify all blocks command the erase verify all blocks command will verify that all p-flash and eeprom blocks have been erased. upon clearing ccif to launch the erase verify all blocks command, the memory controller will verify that the entire flash memory space is erased. the ccif ?g will set after the erase verify all blocks operation has completed. if all blocks are not erased, it means blank check failed, both mgstat bits will be set. table 26-31. erase verify all blocks command fccob requirements ccobix[2:0] fccob parameters 000 0x01 not required table 26-32. erase verify all blocks command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 000 at command launch fpviol none mgstat1 set if any errors have been encountered during the reador if blank check failed . mgstat0 set if any non-correctable errors have been encountered during the read or if blank check failed.
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 914 freescale semiconductor 26.4.6.2 erase verify block command the erase verify block command allows the user to verify that an entire p-flash or eeprom block has been erased. the fccob flashblockselectioncode[1:0] bits determine which block must be veri?d. upon clearing ccif to launch the erase verify block command, the memory controller will verify that the selected p-flash or eeprom block is erased. the ccif ?g will set after the erase verify block operation has completed.if the block is not erased, it means blank check failed, both mgstat bits will be set. 26.4.6.3 erase verify p-flash section command the erase verify p-flash section command will verify that a section of code in the p-flash memory is erased. the erase verify p-flash section command de?es the starting point of the code to be veri?d and the number of phrases. table 26-33. erase verify block command fccob requirements ccobix[2:0] fccob parameters 000 0x02 flash block selection code [1:0] . see table 26-34 table 26-34. flash block selection code description selection code[1:0] flash block to be veri?d 00 eeprom 01 invalid (accerr) 10 invalid (accerr) 11 p-flash table 26-35. erase verify block command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 000 at command launch set if an invalid flashblockselectioncode[1:0] is supplied fpviol none mgstat1 set if any errors have been encountered during the read or if blank check failed. mgstat0 set if any non-correctable errors have been encountered during the read or if blank check failed.
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 915 upon clearing ccif to launch the erase verify p-flash section command, the memory controller will verify the selected section of flash memory is erased. the ccif ?g will set after the erase verify p-flash section operation has completed. if the section is not erased, it means blank check failed, both mgstat bits will be set. 26.4.6.4 read once command the read once command provides read access to a reserved 64 byte ?ld (8 phrases) located in the nonvolatile information register of p-flash. the read once ?ld is programmed using the program once command described in section 26.4.6.6 . the read once command must not be executed from the flash block containing the program once reserved ?ld to avoid code runaway. table 26-36. erase verify p-flash section command fccob requirements ccobix[2:0] fccob parameters 000 0x03 global address [17:16] of a p-flash block 001 global address [15:0] of the ?st phrase to be veri?d 010 number of phrases to be veri?d table 26-37. erase verify p-flash section command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 010 at command launch set if command not available in current mode (see table 26-27 ) set if an invalid global address [17:0] is supplied see table 26-3 ) set if a misaligned phrase address is supplied (global address [2:0] != 000) set if the requested section crosses a the p-flash address boundary fpviol none mgstat1 set if any errors have been encountered during the read or if blank check failed. mgstat0 set if any non-correctable errors have been encountered during the read or if blank check failed. table 26-38. read once command fccob requirements ccobix[2:0] fccob parameters 000 0x04 not required 001 read once phrase index (0x0000 - 0x0007) 010 read once word 0 value 011 read once word 1 value 100 read once word 2 value 101 read once word 3 value
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 916 freescale semiconductor upon clearing ccif to launch the read once command, a read once phrase is fetched and stored in the fccob indexed register. the ccif ?g will set after the read once operation has completed. valid phrase index values for the read once command range from 0x0000 to 0x0007. during execution of the read once command, any attempt to read addresses within p-flash block will return invalid data. 8 26.4.6.5 program p-flash command the program p-flash operation will program a previously erased phrase in the p-flash memory using an embedded algorithm. caution a p-flash phrase must be in the erased state before being programmed. cumulative programming of bits within a flash phrase is not allowed. upon clearing ccif to launch the program p-flash command, the memory controller will program the data words to the supplied global address and will then proceed to verify the data words read back as expected. the ccif ?g will set after the program p-flash operation has completed. table 26-39. read once command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 26-27 ) set if an invalid phrase index is supplied fpviol none mgstat1 set if any errors have been encountered during the read mgstat0 set if any non-correctable errors have been encountered during the read table 26-40. program p-flash command fccob requirements ccobix[2:0] fccob parameters 000 0x06 global address [17:16] to identify p-flash block 001 global address [15:0] of phrase location to be programmed 1 1 global address [2:0] must be 000 010 word 0 program value 011 word 1 program value 100 word 2 program value 101 word 3 program value
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 917 26.4.6.6 program once command the program once command restricts programming to a reserved 64 byte ?ld (8 phrases) in the nonvolatile information register located in p-flash. the program once reserved ?ld can be read using the read once command as described in section 26.4.6.4 . the program once command must only be issued once since the nonvolatile information register in p-flash cannot be erased. the program once command must not be executed from the flash block containing the program once reserved ?ld to avoid code runaway. upon clearing ccif to launch the program once command, the memory controller ?st veri?s that the selected phrase is erased. if erased, then the selected phrase will be programmed and then veri?d with read back. the ccif ?g will remain clear, setting only after the program once operation has completed. the reserved nonvolatile information register accessed by the program once command cannot be erased and any attempt to program one of these phrases a second time will not be allowed. valid phrase index values for the program once command range from 0x0000 to 0x0007. during execution of the program once command, any attempt to read addresses within p-flash will return invalid data. table 26-41. program p-flash command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 101 at command launch set if command not available in current mode (see table 26-27 ) set if an invalid global address [17:0] is supplied see table 26-3 ) set if a misaligned phrase address is supplied (global address [2:0] != 000) fpviol set if the global address [17:0] points to a protected area mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation table 26-42. program once command fccob requirements ccobix[2:0] fccob parameters 000 0x07 not required 001 program once phrase index (0x0000 - 0x0007) 010 program once word 0 value 011 program once word 1 value 100 program once word 2 value 101 program once word 3 value
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 918 freescale semiconductor 26.4.6.7 erase all blocks command the erase all blocks operation will erase the entire p-flash and eeprom memory space. upon clearing ccif to launch the erase all blocks command, the memory controller will erase the entire flash memory space and verify that it is erased. if the memory controller veri?s that the entire flash memory space was properly erased, security will be released. during the execution of this command (ccif=0) the user must not write to any flash module register. the ccif ?g will set after the erase all blocks operation has completed. 26.4.6.8 erase flash block command the erase flash block operation will erase all addresses in a p-flash or eeprom block. table 26-43. program once command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 101 at command launch set if command not available in current mode (see table 26-27 ) set if an invalid phrase index is supplied set if the requested phrase has already been programmed 1 1 if a program once phrase is initially programmed to 0xffff_ffff_ffff_ffff, the program once command will be allowed to execute again on that same phrase. fpviol none mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation table 26-44. erase all blocks command fccob requirements ccobix[2:0] fccob parameters 000 0x08 not required table 26-45. erase all blocks command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 000 at command launch set if command not available in current mode (see table 26-27 ) fpviol set if any area of the p-flash or eeprom memory is protected mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 919 upon clearing ccif to launch the erase flash block command, the memory controller will erase the selected flash block and verify that it is erased. the ccif ?g will set after the erase flash block operation has completed. 26.4.6.9 erase p-flash sector command the erase p-flash sector operation will erase all addresses in a p-flash sector. upon clearing ccif to launch the erase p-flash sector command, the memory controller will erase the selected flash sector and then verify that it is erased. the ccif ?g will be set after the erase p-flash sector operation has completed. table 26-46. erase flash block command fccob requirements ccobix[2:0] fccob parameters 000 0x09 global address [17:16] to identify flash block 001 global address [15:0] in flash block to be erased table 26-47. erase flash block command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 26-27 ) set if an invalid global address [17:16] is supplied set if the supplied p-flash address is not phrase-aligned or if the eeprom address is not word-aligned fpviol set if an area of the selected flash block is protected mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation table 26-48. erase p-flash sector command fccob requirements ccobix[2:0] fccob parameters 000 0x0a global address [17:16] to identify p-flash block to be erased 001 global address [15:0] anywhere within the sector to be erased. refer to section 26.1.2.1 for the p-flash sector size.
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 920 freescale semiconductor 26.4.6.10 unsecure flash command the unsecure flash command will erase the entire p-flash and eeprom memory space and, if the erase is successful, will release security. upon clearing ccif to launch the unsecure flash command, the memory controller will erase the entire p-flash and eeprom memory space and verify that it is erased. if the memory controller veri?s that the entire flash memory space was properly erased, security will be released. if the erase verify is not successful, the unsecure flash operation sets mgstat1 and terminates without changing the security state. during the execution of this command (ccif=0) the user must not write to any flash module register. the ccif ?g is set after the unsecure flash operation has completed. 26.4.6.11 verify backdoor access key command the verify backdoor access key command will only execute if it is enabled by the keyen bits in the fsec register (see table 26-10 ). the verify backdoor access key command releases security if user-supplied keys match those stored in the flash security bytes of the flash con?uration ?ld (see table 26-49. erase p-flash sector command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 26-27 ) set if an invalid global address [17:16] is supplied see table 26-3 ) set if a misaligned phrase address is supplied (global address [2:0] != 000) fpviol set if the selected p-flash sector is protected mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation table 26-50. unsecure flash command fccob requirements ccobix[2:0] fccob parameters 000 0x0b not required table 26-51. unsecure flash command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 000 at command launch set if command not available in current mode (see table 26-27 ) fpviol set if any area of the p-flash or eeprom memory is protected mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 921 table 26-4 ). the verify backdoor access key command must not be executed from the flash block containing the backdoor comparison key to avoid code runaway. upon clearing ccif to launch the verify backdoor access key command, the memory controller will check the fsec keyen bits to verify that this command is enabled. if not enabled, the memory controller sets the accerr bit in the fstat register and terminates. if the command is enabled, the memory controller compares the key provided in fccob to the backdoor comparison key in the flash con?uration ?ld with key 0 compared to 0x3_ff00, etc. if the backdoor keys match, security will be released. if the backdoor keys do not match, security is not released and all future attempts to execute the verify backdoor access key command are aborted (set accerr) until a reset occurs. the ccif flag is set after the verify backdoor access key operation has completed. 26.4.6.12 set user margin level command the set user margin level command causes the memory controller to set the margin level for future read operations of the p-flash or eeprom block. table 26-52. verify backdoor access key command fccob requirements ccobix[2:0] fccob parameters 000 0x0c not required 001 key 0 010 key 1 011 key 2 100 key 3 table 26-53. verify backdoor access key command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 100 at command launch set if an incorrect backdoor key is supplied set if backdoor key access has not been enabled (keyen[1:0] != 10, see section 26.3.2.2 ) set if the backdoor key has mismatched since the last reset fpviol none mgstat1 none mgstat0 none table 26-54. set user margin level command fccob requirements ccobix[2:0] fccob parameters 000 0x0d flash block selection code [1:0] . see 001 margin level setting.
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 922 freescale semiconductor upon clearing ccif to launch the set user margin level command, the memory controller will set the user margin level for the targeted block and then set the ccif ?g. note when the eeprom block is targeted, the eeprom user margin levels are applied only to the eeprom reads. however, when the p-flash block is targeted, the p-flash user margin levels are applied to both p-flash and eeprom reads. it is not possible to apply user margin levels to the p-flash block only. valid margin level settings for the set user margin level command are de?ed in table 26-55 . note user margin levels can be used to check that flash memory contents have adequate margin for normal level read operations. if unexpected results are encountered when checking flash memory contents at user margin levels, a potential loss of information has been detected. table 26-55. valid set user margin level settings ccob (ccobix=001) level description 0x0000 return to normal level 0x0001 user margin-1 level 1 1 read margin to the erased state 0x0002 user margin-0 level 2 2 read margin to the programmed state table 26-56. set user margin level command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 26-27 ) set if an invalid flashblockselectioncode[1:0] is supplied (see table 26-34 ) set if an invalid margin level setting is supplied fpviol none mgstat1 none mgstat0 none
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 923 26.4.6.13 set field margin level command the set field margin level command, valid in special modes only, causes the memory controller to set the margin level speci?d for future read operations of the p-flash or eeprom block. upon clearing ccif to launch the set field margin level command, the memory controller will set the ?ld margin level for the targeted block and then set the ccif ?g. note when the eeprom block is targeted, the eeprom ?ld margin levels are applied only to the eeprom reads. however, when the p-flash block is targeted, the p-flash ?ld margin levels are applied to both p-flash and eeprom reads. it is not possible to apply ?ld margin levels to the p-flash block only. valid margin level settings for the set field margin level command are de?ed in table 26-58 . table 26-57. set field margin level command fccob requirements ccobix[2:0] fccob parameters 000 0x0e flash block selection code [1:0] . see table 26-34 001 margin level setting. table 26-58. valid set field margin level settings ccob (ccobix=001) level description 0x0000 return to normal level 0x0001 user margin-1 level 1 1 read margin to the erased state 0x0002 user margin-0 level 2 2 read margin to the programmed state 0x0003 field margin-1 level 1 0x0004 field margin-0 level 2
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 924 freescale semiconductor caution field margin levels must only be used during verify of the initial factory programming. note field margin levels can be used to check that flash memory contents have adequate margin for data retention at the normal level setting. if unexpected results are encountered when checking flash memory contents at ?ld margin levels, the flash memory contents should be erased and reprogrammed. 26.4.6.14 erase verify eeprom section command the erase verify eeprom section command will verify that a section of code in the eeprom is erased. the erase verify eeprom section command de?es the starting point of the data to be veri?d and the number of words. upon clearing ccif to launch the erase verify eeprom section command, the memory controller will verify the selected section of eeprom memory is erased. the ccif ?g will set after the erase verify eeprom section operation has completed. if the section is not erased, it means blank check failed, both mgstat bits will be set. table 26-59. set field margin level command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 26-27 ) set if an invalid flashblockselectioncode[1:0] is supplied (see table 26-34 ) set if an invalid margin level setting is supplied fpviol none mgstat1 none mgstat0 none table 26-60. erase verify eeprom section command fccob requirements ccobix[2:0] fccob parameters 000 0x10 global address [17:16] to identify the eeprom block 001 global address [15:0] of the ?st word to be veri?d 010 number of words to be veri?d
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 925 26.4.6.15 program eeprom command the program eeprom operation programs one to four previously erased words in the eeprom block. the program eeprom operation will con?m that the targeted location(s) were successfully programmed upon completion. caution a flash word must be in the erased state before being programmed. cumulative programming of bits within a flash word is not allowed. upon clearing ccif to launch the program eeprom command, the user-supplied words will be transferred to the memory controller and be programmed if the area is unprotected. the ccobix index value at program eeprom command launch determines how many words will be programmed in the eeprom block. the ccif ?g is set when the operation has completed. table 26-61. erase verify eeprom section command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 010 at command launch set if command not available in current mode (see table 26-27 ) set if an invalid global address [17:0] is supplied set if a misaligned word address is supplied (global address [0] != 0) set if the requested section breaches the end of the eeprom block fpviol none mgstat1 set if any errors have been encountered during the read or if blank check failed. mgstat0 set if any non-correctable errors have been encountered during the read or if blank check failed. table 26-62. program eeprom command fccob requirements ccobix[2:0] fccob parameters 000 0x11 global address [17:16] to identify the eeprom block 001 global address [15:0] of word to be programmed 010 word 0 program value 011 word 1 program value, if desired 100 word 2 program value, if desired 101 word 3 program value, if desired
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 926 freescale semiconductor 26.4.6.16 erase eeprom sector command the erase eeprom sector operation will erase all addresses in a sector of the eeprom block. upon clearing ccif to launch the erase eeprom sector command, the memory controller will erase the selected flash sector and verify that it is erased. the ccif ?g will set after the erase eeprom sector operation has completed. table 26-63. program eeprom command error handling register error bit error condition fstat accerr set if ccobix[2:0] < 010 at command launch set if ccobix[2:0] > 101 at command launch set if command not available in current mode (see table 26-27 ) set if an invalid global address [17:0] is supplied set if a misaligned word address is supplied (global address [0] != 0) set if the requested group of words breaches the end of the eeprom block fpviol set if the selected area of the eeprom memory is protected mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation table 26-64. erase eeprom sector command fccob requirements ccobix[2:0] fccob parameters 000 0x12 global address [17:16] to identify eeprom block 001 global address [15:0] anywhere within the sector to be erased. see section 26.1.2.2 for eeprom sector size. table 26-65. erase eeprom sector command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 26-27 ) set if an invalid global address [17:0] is suppliedsee table 26-3 ) set if a misaligned word address is supplied (global address [0] != 0) fpviol set if the selected area of the eeprom memory is protected mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 927 26.4.7 interrupts the flash module can generate an interrupt when a flash command operation has completed or when a flash command operation has detected an ecc fault. note vector addresses and their relative interrupt priority are determined at the mcu level. 26.4.7.1 description of flash interrupt operation the flash module uses the ccif ?g in combination with the ccie interrupt enable bit to generate the flash command interrupt request. the flash module uses the dfdif and sfdif ?gs in combination with the dfdie and sfdie interrupt enable bits to generate the flash error interrupt request. for a detailed description of the register bits involved, refer to section 26.3.2.5, ?lash configuration register (fcnfg) ? section 26.3.2.6, ?lash error configuration register (fercnfg) ? section 26.3.2.7, ?lash status register (fstat) ? and section 26.3.2.8, ?lash error status register (ferstat) ? the logic used for generating the flash module interrupts is shown in figure 26-27 . figure 26-27. flash module interrupts implementation table 26-66. flash interrupt sources interrupt source interrupt flag local enable global (ccr) mask flash command complete ccif (fstat register) ccie (fcnfg register) i bit ecc double bit fault on flash read dfdif (ferstat register) dfdie (fercnfg register) i bit ecc single bit fault on flash read sfdif (ferstat register) sfdie (fercnfg register) i bit flash error interrupt request ccif ccie dfdif dfdie sfdif sfdie flash command interrupt request
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 928 freescale semiconductor 26.4.8 wait mode the flash module is not affected if the mcu enters wait mode. the flash module can recover the mcu from wait via the ccif interrupt (see section 26.4.7, ?nterrupts ). 26.4.9 stop mode if a flash command is active (ccif = 0) when the mcu requests stop mode, the current flash operation will be completed before the mcu is allowed to enter stop mode. 26.5 security the flash module provides security information to the mcu. the flash security state is de?ed by the sec bits of the fsec register (see table 26-11 ). during reset, the flash module initializes the fsec register using data read from the security byte of the flash con?uration ?ld at global address 0x3_ff0f. the security state out of reset can be permanently changed by programming the security byte assuming that the mcu is starting from a mode where the necessary p-flash erase and program commands are available and that the upper region of the p-flash is unprotected. if the flash security byte is successfully programmed, its new value will take affect after the next mcu reset. the following subsections describe these security-related subjects: unsecuring the mcu using backdoor key access unsecuring the mcu in special single chip mode using bdm mode and security effects on flash command availability 26.5.1 unsecuring the mcu using backdoor key access the mcu may be unsecured by using the backdoor key access feature which requires knowledge of the contents of the backdoor keys (four 16-bit words programmed at addresses 0x3_ff00-0x3_ff07). if the keyen[1:0] bits are in the enabled state (see section 26.3.2.2 ), the verify backdoor access key command (see section 26.4.6.11 ) allows the user to present four prospective keys for comparison to the keys stored in the flash memory via the memory controller. if the keys presented in the verify backdoor access key command match the backdoor keys stored in the flash memory, the sec bits in the fsec register (see table 26-11 ) will be changed to unsecure the mcu. key values of 0x0000 and 0xffff are not permitted as backdoor keys. while the verify backdoor access key command is active, p-flash memory and eeprom memory will not be available for read access and will return invalid data.
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 929 the user code stored in the p-flash memory must have a method of receiving the backdoor keys from an external stimulus. this external stimulus would typically be through one of the on-chip serial ports. if the keyen[1:0] bits are in the enabled state (see section 26.3.2.2 ), the mcu can be unsecured by the backdoor key access sequence described below: 1. follow the command sequence for the verify backdoor access key command as explained in section 26.4.6.11 2. if the verify backdoor access key command is successful, the mcu is unsecured and the sec[1:0] bits in the fsec register are forced to the unsecure state of 10 the verify backdoor access key command is monitored by the memory controller and an illegal key will prohibit future use of the verify backdoor access key command. a reset of the mcu is the only method to re-enable the verify backdoor access key command. the security as de?ed in the flash security byte (0x3_ff0f) is not changed by using the verify backdoor access key command sequence. the backdoor keys stored in addresses 0x3_ff00-0x3_ff07 are unaffected by the verify backdoor access key command sequence. the verify backdoor access key command sequence has no effect on the program and erase protections de?ed in the flash protection register, fprot. after the backdoor keys have been correctly matched, the mcu will be unsecured. after the mcu is unsecured, the sector containing the flash security byte can be erased and the flash security byte can be reprogrammed to the unsecure state, if desired. in the unsecure state, the user has full control of the contents of the backdoor keys by programming addresses 0x3_ff00-0x3_ff07 in the flash con?uration ?ld. 26.5.2 unsecuring the mcu in special single chip mode using bdm a secured mcu can be unsecured in special single chip mode by using the following method to erase the p-flash and eeprom memory: 1. reset the mcu into special single chip mode 2. delay while the bdm executes the erase verify all blocks command write sequence to check if the p-flash and eeprom memories are erased 3. send bdm commands to disable protection in the p-flash and eeprom memory 4. execute the erase all blocks command write sequence to erase the p-flash and eeprom memory. alternatively the unsecure flash command can be executed, if so the steps 5 and 6 below are skeeped. 5. after the ccif ?g sets to indicate that the erase all blocks operation has completed, reset the mcu into special single chip mode 6. delay while the bdm executes the erase verify all blocks command write sequence to verify that the p-flash and eeprom memory are erased if the p-flash and eeprom memory are veri?d as erased, the mcu will be unsecured. all bdm commands will now be enabled and the flash security byte may be programmed to the unsecure state by continuing with the following steps: 7. send bdm commands to execute the program p-flash command write sequence to program the flash security byte to the unsecured state
48 kbyte flash module (s12ftmrg48k1v1) mc9s12g family reference manual, rev.1.23 930 freescale semiconductor 8. reset the mcu 26.5.3 mode and security effects on flash command availability the availability of flash module commands depends on the mcu operating mode and security state as shown in table 26-27 . 26.6 initialization on each system reset the ?sh module executes an initialization sequence which establishes initial values for the flash block con?uration parameters, the fprot and eeprot protection registers, and the fopt and fsec registers. the initialization routine reverts to built-in default values that leave the module in a fully protected and secured state if errors are encountered during execution of the reset sequence. if a double bit fault is detected during the reset sequence, both mgstat bits in the fstat register will be set. ccif is cleared throughout the initialization sequence. the flash module holds off all cpu access for a portion of the initialization sequence. flash reads are allowed once the hold is removed. completion of the initialization sequence is marked by setting ccif high which enables user commands. if a reset occurs while any flash command is in progress, that command will be immediately aborted. the state of the word being programmed or the sector/block being erased is not guaranteed.
mc9s12g family reference manual, rev.1.23 freescale semiconductor 931 chapter 27 64 kbyte flash module (s12ftmrg64k1v1) 27.1 introduction the ftmrg64k1 module implements the following: 64kbytes of p-flash (program flash) memory 2 kbytes of eeprom memory the flash memory is ideal for single-supply applications allowing for ?ld reprogramming without requiring external high voltage sources for program or erase operations. the flash module includes a memory controller that executes commands to modify flash memory contents. the user interface to the memory controller consists of the indexed flash common command object (fccob) register which is written to with the command, global address, data, and any required command parameters. the memory controller must complete the execution of a command before the fccob register can be written to with a new command. caution a flash word or phrase must be in the erased state before being programmed. cumulative programming of bits within a flash word or phrase is not allowed. table 27-1. revision history revision number revision date sections affected description of changes v01.04 17 jun 2010 27.4.6.1/27-964 27.4.6.2/27-965 27.4.6.3/27-965 27.4.6.14/27-97 5 clarify erase verify commands descriptions related to the bits mgstat[1:0] of the register fstat. v01.05 20 aug 2010 27.4.6.2/27-965 27.4.6.12/27-97 2 27.4.6.13/27-97 4 updated description of the commands rd1blk, mloadu and mloadf rev.1.23 31 jan 2011 27.3.2.9/27-947 updated description of protection on section 27.3.2.9
mc9s12g family reference manual, rev.1.23 freescale semiconductor 932 the flash memory may be read as bytes and aligned words. read access time is one bus cycle for bytes and aligned words. for misaligned words access, the cpu has to perform twice the byte read access command. for flash memory, an erased bit reads 1 and a programmed bit reads 0. it is possible to read from p-flash memory while some commands are executing on eeprom memory. it is not possible to read from eeprom memory while a command is executing on p-flash memory. simultaneous p-flash and eeprom operations are discussed in section 27.4.5 . both p-flash and eeprom memories are implemented with error correction codes (ecc) that can resolve single bit faults and detect double bit faults. for p-flash memory, the ecc implementation requires that programming be done on an aligned 8 byte basis (a flash phrase). since p-flash memory is always read by half-phrase, only one single bit fault in an aligned 4 byte half-phrase containing the byte or word accessed will be corrected. 27.1.1 glossary command write sequence ?an mcu instruction sequence to execute built-in algorithms (including program and erase) on the flash memory. eeprom memory ?the eeprom memory constitutes the nonvolatile memory store for data. eeprom sector ?the eeprom sector is the smallest portion of the eeprom memory that can be erased. the eeprom sector consists of 4 bytes. nvm command mode an nvm mode using the cpu to setup the fccob register to pass parameters required for flash command execution. phrase ?an aligned group of four 16-bit words within the p-flash memory. each phrase includes two sets of aligned double words with each set including 7 ecc bits for single bit fault correction and double bit fault detection within each double word. p-flash memory the p-flash memory constitutes the main nonvolatile memory store for applications. p-flash sector ?the p-flash sector is the smallest portion of the p-flash memory that can be erased. each p-flash sector contains 512 bytes. program ifr ?nonvolatile information register located in the p-flash block that contains the version id, and the program once ?ld. 27.1.2 features 27.1.2.1 p-flash features 64 kbytes of p-flash memory composed of one 64 kbyte flash block divided into 128 sectors of 512 bytes
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 933 single bit fault correction and double bit fault detection within a 32-bit double word during read operations automated program and erase algorithm with verify and generation of ecc parity bits fast sector erase and phrase program operation ability to read the p-flash memory while programming a word in the eeprom memory flexible protection scheme to prevent accidental program or erase of p-flash memory 27.1.2.2 eeprom features 2 kbytes of eeprom memory composed of one 2 kbyte flash block divided into 512 sectors of 4 bytes single bit fault correction and double bit fault detection within a word during read operations automated program and erase algorithm with verify and generation of ecc parity bits fast sector erase and word program operation protection scheme to prevent accidental program or erase of eeprom memory ability to program up to four words in a burst sequence 27.1.2.3 other flash module features no external high-voltage power supply required for flash memory program and erase operations interrupt generation on flash command completion and flash error detection security mechanism to prevent unauthorized access to the flash memory 27.1.3 block diagram the block diagram of the flash module is shown in figure 27-1 .
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 934 freescale semiconductor figure 27-1. ftmrg64k1 block diagram 27.2 external signal description the flash module contains no signals that connect off-chip. bus clock divider clock command interrupt request fclk protection security registers flash interface 16bit internal bus sector 0 sector 1 sector 127 16kx39 p-flash error interrupt request cpu 1kx22 sector 0 sector 1 sector 511 eeprom memory controller
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 935 27.3 memory map and registers this section describes the memory map and registers for the flash module. read data from unimplemented memory space in the flash module is unde?ed. write access to unimplemented or reserved memory space in the flash module will be ignored by the flash module. caution writing to the flash registers while a flash command is executing (that is indicated when the value of ?g ccif reads as ?? is not allowed. if such action is attempted the write operation will not change the register value. writing to the flash registers is allowed when the flash is not busy executing commands (ccif = 1) and during initialization right after reset, despite the value of ?g ccif in that case (refer to section 27.6 for a complete description of the reset sequence). . 27.3.1 module memory map the s12 architecture places the p-flash memory between global addresses 0x3_0000 and 0x3_ffff as shown in table 27-3 .the p-flash memory map is shown in figure 27-2 . table 27-2. ftmrg memory map global address (in bytes) size (bytes) description 0x0_0000 - 0x0_03ff 1,024 register space 0x0_0400 ?0x0_0bff 2,048 eeprom memory 0x0_4000 ?0x0_7fff 16,284 nvmres 1 =1 : nvm resource area (see figure 27-3 ) 1 see nvmres description in section 27.4.3 0x3_0000 ?0x3_ffff 65,536 p-flash memory table 27-3. p-flash memory addressing global address size (bytes) description 0x3_0000 ?0x3_ffff 64 k p-flash block contains flash con?uration field (see table 27-4 )
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 936 freescale semiconductor the fprot register, described in section 27.3.2.9 , can be set to protect regions in the flash memory from accidental program or erase. three separate memory regions, one growing upward from global address 0x3_8000 in the flash memory (called the lower region), one growing downward from global address 0x3_ffff in the flash memory (called the higher region), and the remaining addresses in the flash memory, can be activated for protection. the flash memory addresses covered by these protectable regions are shown in the p-flash memory map. the higher address region is mainly targeted to hold the boot loader code since it covers the vector space. default protection settings as well as security information that allows the mcu to restrict access to the flash module are stored in the flash con?uration ?ld as described in table 27-4 . table 27-4. flash con?uration field global address size (bytes) description 0x3_ff00-0x3_ff07 8 backdoor comparison key refer to section 27.4.6.11, ?erify backdoor access key command , and section 27.5.1, ?nsecuring the mcu using backdoor key access 0x3_ff08-0x3_ff0b 1 1 0x3ff08-0x3_ff0f form a flash phrase and must be programmed in a single command write sequence. each byte in the 0x3_ff08 - 0x3_ff0b reserved ?ld should be programmed to 0xff. 4 reserved 0x3_ff0c 1 1 p-flash protection byte . refer to section 27.3.2.9, ?-flash protection register (fprot) 0x3_ff0d 1 1 eeprom protection byte . refer to section 27.3.2.10, ?eprom protection register (eeprot) 0x3_ff0e 1 1 flash nonvolatile byte refer to section 27.3.2.16, ?lash option register (fopt) 0x3_ff0f 1 1 flash security byte refer to section 27.3.2.2, ?lash security register (fsec)
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 937 figure 27-2. p-flash memory map table 27-5. program ifr fields global address size (bytes) field description 0x0_4000 ?0x0_4007 8 reserved 0x0_4008 ?0x0_40b5 174 reserved 0x0_40b6 ?0x0_40b7 2 version id 1 1 used to track ?mware patch versions, see section 27.4.2 0x0_40b8 ?0x0_40bf 8 reserved 0x0_40c0 ?0x0_40ff 64 program once field refer to section 27.4.6.6, ?rogram once command flash con?uration field 0x3_c000 flash protected/unprotected lower region 1, 2, 4, 8 kbytes 0x3_8000 0x3_9000 0x3_8400 0x3_8800 0x3_a000 p-flash end = 0x3_ffff 0x3_f800 0x3_f000 0x3_e000 flash protected/unprotected higher region 2, 4, 8, 16 kbytes flash protected/unprotected region 8 kbytes (up to 29 kbytes) 16 bytes (0x3_ff00 - 0x3_ff0f) flash protected/unprotected region 32 kbytes p-flash start = 0x3_0000 protection protection protection movable end fixed end fixed end
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 938 freescale semiconductor figure 27-3. memory controller resource memory map (nvmres=1) 27.3.2 register descriptions the flash module contains a set of 20 control and status registers located between flash module base + 0x0000 and 0x0013. in the case of the writable registers, the write accesses are forbidden during fash command execution (for more detail, see caution note in section 27.3 ). table 27-6. memory controller resource fields (nvmres 1 =1) 1 nvmres - see section 27.4.3 for nvmres (nvm resource) detail. global address size (bytes) description 0x0_4000 ?0x040ff 256 p-flash ifr (see table 27-5 ) 0x0_4100 ?0x0_41ff 256 reserved. 0x0_4200 ?0x0_57ff reserved 0x0_5800 ?0x0_59ff 512 reserved 0x0_5a00 ?0x0_5fff 1,536 reserved 0x0_6000 ?0x0_6bff 3,072 reserved 0x0_6c00 ?0x0_7fff 5,120 reserved p-flash ifr 1 kbyte (nvmres=1) 0x0_4000 ram end = 0x0_59ff ram start = 0x0_5800 reserved 5120 bytes reserved 4608 bytes 0x0_6c00 0x0_7fff 0x0_4400 reserved 5k bytes reserved 512 bytes
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 939 a summary of the flash module registers is given in figure 27-4 with detailed descriptions in the following subsections. address & name 76543210 0x0000 fclkdiv r fdivld fdivlck fdiv5 fdiv4 fdiv3 fdiv2 fdiv1 fdiv0 w 0x0001 fsec r keyen1 keyen0 rnv5 rnv4 rnv3 rnv2 sec1 sec0 w 0x0002 fccobix r0 0 0 0 0 ccobix2 ccobix1 ccobix0 w 0x0003 frsv0 r00000000 w 0x0004 fcnfg r ccie 00 ignsf 00 fdfd fsfd w 0x0005 fercnfg r0 0 0 0 0 0 dfdie sfdie w 0x0006 fstat r ccif 0 accerr fpviol mgbusy rsvd mgstat1 mgstat0 w 0x0007 ferstat r0 0 0 0 0 0 dfdif sfdif w 0x0008 fprot r fpopen rnv6 fphdis fphs1 fphs0 fpldis fpls1 fpls0 w 0x0009 eeprot r dpopen 0 dps5 dps4 dps3 dps2 dps1 dps0 w 0x000a fccobhi r ccob15 ccob14 ccob13 ccob12 ccob11 ccob10 ccob9 ccob8 w 0x000b fccoblo r ccob7 ccob6 ccob5 ccob4 ccob3 ccob2 ccob1 ccob0 w 0x000c frsv1 r00000000 w figure 27-4. ftmrg64k1 register summary
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 940 freescale semiconductor 27.3.2.1 flash clock divider register (fclkdiv) the fclkdiv register is used to control timed events in program and erase algorithms. all bits in the fclkdiv register are readable, bit 7 is not writable, bit 6 is write-once-hi and controls the writability of the fdiv ?ld in normal mode. in special mode, bits 6-0 are writable any number of times but bit 7 remains unwritable. 0x000d frsv2 r00000000 w 0x000e frsv3 r00000000 w 0x000f frsv4 r00000000 w 0x0010 fopt r nv7 nv6 nv5 nv4 nv3 nv2 nv1 nv0 w 0x0011 frsv5 r00000000 w 0x0012 frsv6 r00000000 w 0x0013 frsv7 r00000000 w = unimplemented or reserved offset module base + 0x0000 76543210 r fdivld fdivlck fdiv[5:0] w reset 00000000 = unimplemented or reserved figure 27-5. flash clock divider register (fclkdiv) address & name 76543210 figure 27-4. ftmrg64k1 register summary (continued)
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 941 caution the fclkdiv register should never be written while a flash command is executing (ccif=0). table 27-7. fclkdiv field descriptions field description 7 fdivld clock divider loaded 0 fclkdiv register has not been written since the last reset 1 fclkdiv register has been written since the last reset 6 fdivlck clock divider locked 0 fdiv ?ld is open for writing 1 fdiv value is locked and cannot be changed. once the lock bit is set high, only reset can clear this bit and restore writability to the fdiv ?ld in normal mode. 5? fdiv[5:0] clock divider bits fdiv[5:0] must be set to effectively divide busclk down to 1 mhz to control timed events during flash program and erase algorithms. table 27-8 shows recommended values for fdiv[5:0] based on the busclk frequency. please refer to section 27.4.4, ?lash command operations , for more information. table 27-8. fdiv values for various busclk frequencies busclk frequency (mhz) fdiv[5:0] busclk frequency (mhz) fdiv[5:0] min 1 1 busclk is greater than this value. max 2 2 busclk is less than or equal to this value. min 1 max 2 1.0 1.6 0x00 16.6 17.6 0x10 1.6 2.6 0x01 17.6 18.6 0x11 2.6 3.6 0x02 18.6 19.6 0x12 3.6 4.6 0x03 19.6 20.6 0x13 4.6 5.6 0x04 20.6 21.6 0x14 5.6 6.6 0x05 21.6 22.6 0x15 6.6 7.6 0x06 22.6 23.6 0x16 7.6 8.6 0x07 23.6 24.6 0x17 8.6 9.6 0x08 24.6 25.6 0x18 9.6 10.6 0x09 10.6 11.6 0x0a 11.6 12.6 0x0b 12.6 13.6 0x0c 13.6 14.6 0x0d 14.6 15.6 0x0e 15.6 16.6 0x0f
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 942 freescale semiconductor 27.3.2.2 flash security register (fsec) the fsec register holds all bits associated with the security of the mcu and flash module. all bits in the fsec register are readable but not writable. during the reset sequence, the fsec register is loaded with the contents of the flash security byte in the flash con?uration ?ld at global address 0x3_ff0f located in p-flash memory (see table 27-4 ) as indicated by reset condition f in figure 27-6 . if a double bit fault is detected while reading the p-flash phrase containing the flash security byte during the reset sequence, all bits in the fsec register will be set to leave the flash module in a secured state with backdoor key access disabled. offset module base + 0x0001 76543210 r keyen[1:0] rnv[5:2] sec[1:0] w reset f 1 1 loaded from ifr flash con?uration ?ld, during reset sequence. f 1 f 1 f 1 f 1 f 1 f 1 f 1 = unimplemented or reserved figure 27-6. flash security register (fsec) table 27-9. fsec field descriptions field description 7? keyen[1:0] backdoor key security enable bits the keyen[1:0] bits de?e the enabling of backdoor key access to the flash module as shown in table 27-10 . 5? rnv[5:2] reserved nonvolatile bits ?the rnv bits should remain in the erased state for future enhancements. 1? sec[1:0] flash security bits ?the sec[1:0] bits de?e the security state of the mcu as shown in table 27-11 . if the flash module is unsecured using backdoor key access, the sec bits are forced to 10. table 27-10. flash keyen states keyen[1:0] status of backdoor key access 00 disabled 01 disabled 1 1 preferred keyen state to disable backdoor key access. 10 enabled 11 disabled
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 943 the security function in the flash module is described in section 27.5 . 27.3.2.3 flash ccob index register (fccobix) the fccobix register is used to index the fccob register for flash memory operations. ccobix bits are readable and writable while remaining bits read 0 and are not writable. 27.3.2.4 flash reserved0 register (frsv0) this flash register is reserved for factory testing. all bits in the frsv0 register read 0 and are not writable. table 27-11. flash security states sec[1:0] status of security 00 secured 01 secured 1 1 preferred sec state to set mcu to secured state. 10 unsecured 11 secured offset module base + 0x0002 76543210 r00000 ccobix[2:0] w reset 00000000 = unimplemented or reserved figure 27-7. fccob index register (fccobix) table 27-12. fccobix field descriptions field description 2? ccobix[1:0] common command register index the ccobix bits are used to select which word of the fccob register array is being read or written to. see 27.3.2.11 flash common command object register (fccob), for more details. offset module base + 0x000c 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 27-8. flash reserved0 register (frsv0)
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 944 freescale semiconductor 27.3.2.5 flash con?uration register (fcnfg) the fcnfg register enables the flash command complete interrupt and forces ecc faults on flash array read access from the cpu. ccie, ignsf, fdfd, and fsfd bits are readable and writable while remaining bits read 0 and are not writable. 27.3.2.6 flash error con?uration register (fercnfg) the fercnfg register enables the flash error interrupts for the ferstat ?gs. offset module base + 0x0004 76543210 r ccie 00 ignsf 00 fdfd fsfd w reset 00000000 = unimplemented or reserved figure 27-9. flash con?uration register (fcnfg) table 27-13. fcnfg field descriptions field description 7 ccie command complete interrupt enable ?the ccie bit controls interrupt generation when a flash command has completed. 0 command complete interrupt disabled 1 an interrupt will be requested whenever the ccif ?g in the fstat register is set (see section 27.3.2.7 ) 4 ignsf ignore single bit fault ?the ignsf controls single bit fault reporting in the ferstat register (see section 27.3.2.8 ). 0 all single bit faults detected during array reads are reported 1 single bit faults detected during array reads are not reported and the single bit fault interrupt will not be generated 1 fdfd force double bit fault detect the fdfd bit allows the user to simulate a double bit fault during flash array read operations and check the associated interrupt routine. the fdfd bit is cleared by writing a 0 to fdfd. 0 flash array read operations will set the dfdif ?g in the ferstat register only if a double bit fault is detected 1 any flash array read operation will force the dfdif ?g in the ferstat register to be set (see section 27.3.2.7 ) and an interrupt will be generated as long as the dfdie interrupt enable in the fercnfg register is set (see section 27.3.2.6 ) 0 fsfd force single bit fault detect the fsfd bit allows the user to simulate a single bit fault during flash array read operations and check the associated interrupt routine. the fsfd bit is cleared by writing a 0 to fsfd. 0 flash array read operations will set the sfdif ?g in the ferstat register only if a single bit fault is detected 1 flash array read operation will force the sfdif ?g in the ferstat register to be set (see section 27.3.2.7 ) and an interrupt will be generated as long as the sfdie interrupt enable in the fercnfg register is set (see section 27.3.2.6 )
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 945 all assigned bits in the fercnfg register are readable and writable. 27.3.2.7 flash status register (fstat) the fstat register reports the operational status of the flash module. ccif, accerr, and fpviol bits are readable and writable, mgbusy and mgstat bits are readable but not writable, while remaining bits read 0 and are not writable. offset module base + 0x0005 76543210 r000000 dfdie sfdie w reset 00000000 = unimplemented or reserved figure 27-10. flash error con?uration register (fercnfg) table 27-14. fercnfg field descriptions field description 1 dfdie double bit fault detect interrupt enable the dfdie bit controls interrupt generation when a double bit fault is detected during a flash block read operation. 0 dfdif interrupt disabled 1 an interrupt will be requested whenever the dfdif ?g is set (see section 27.3.2.8 ) 0 sfdie single bit fault detect interrupt enable the sfdie bit controls interrupt generation when a single bit fault is detected during a flash block read operation. 0 sfdif interrupt disabled whenever the sfdif ?g is set (see section 27.3.2.8 ) 1 an interrupt will be requested whenever the sfdif ?g is set (see section 27.3.2.8 ) offset module base + 0x0006 76543210 r ccif 0 accerr fpviol mgbusy rsvd mgstat[1:0] w reset 1000000 1 1 reset value can deviate from the value shown if a double bit fault is detected during the reset sequence (see section 27.6 ). 0 1 = unimplemented or reserved figure 27-11. flash status register (fstat)
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 946 freescale semiconductor 27.3.2.8 flash error status register (ferstat) the ferstat register re?cts the error status of internal flash operations. all ?gs in the ferstat register are readable and only writable to clear the ?g. table 27-15. fstat field descriptions field description 7 ccif command complete interrupt flag ?the ccif ?g indicates that a flash command has completed. the ccif ?g is cleared by writing a 1 to ccif to launch a command and ccif will stay low until command completion or command violation. 0 flash command in progress 1 flash command has completed 5 accerr flash access error flag ?the accerr bit indicates an illegal access has occurred to the flash memory caused by either a violation of the command write sequence (see section 27.4.4.2 ) or issuing an illegal flash command. while accerr is set, the ccif ?g cannot be cleared to launch a command. the accerr bit is cleared by writing a 1 to accerr. writing a 0 to the accerr bit has no effect on accerr. 0 no access error detected 1 access error detected 4 fpviol flash protection violation flag ?he fpviol bit indicates an attempt was made to program or erase an address in a protected area of p-flash or eeprom memory during a command write sequence. the fpviol bit is cleared by writing a 1 to fpviol. writing a 0 to the fpviol bit has no effect on fpviol. while fpviol is set, it is not possible to launch a command or start a command write sequence. 0 no protection violation detected 1 protection violation detected 3 mgbusy memory controller busy flag ?the mgbusy ?g re?cts the active state of the memory controller . 0 memory controller is idle 1 memory controller is busy executing a flash command (ccif = 0) 2 rsvd reserved bit ?this bit is reserved and always reads 0 . 1? mgstat[1:0] memory controller command completion status flag one or more mgstat ?g bits are set if an error is detected during execution of a flash command or during the flash reset sequence. see section 27.4.6, ?lash command description , and section 27.6, ?nitialization ?for details. offset module base + 0x0007 76543210 r000000 dfdif sfdif w reset 00000000 = unimplemented or reserved figure 27-12. flash error status register (ferstat)
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 947 27.3.2.9 p-flash protection register (fprot) the fprot register de?es which p-flash sectors are protected against program and erase operations. the (unreserved) bits of the fprot register are writable with the restriction that the size of the protected region can only be increased (see section 27.3.2.9.1, ?-flash protection restrictions , and table 27-21 ). during the reset sequence, the fprot register is loaded with the contents of the p-flash protection byte in the flash con?uration ?ld at global address 0x3_ff0c located in p-flash memory (see table 27-4 ) as indicated by reset condition ??in figure 27-13 . to change the p-flash protection that will be loaded during the reset sequence, the upper sector of the p-flash memory must be unprotected, then the p-flash protection byte must be reprogrammed. if a double bit fault is detected while reading the p-flash phrase containing the p-flash protection byte during the reset sequence, the fpopen bit will be cleared and remaining bits in the fprot register will be set to leave the p-flash memory fully protected. table 27-16. ferstat field descriptions field description 1 dfdif double bit fault detect interrupt flag ?the setting of the dfdif ?g indicates that a double bit fault was detected in the stored parity and data bits during a flash array read operation or that a flash array read operation returning invalid data was attempted on a flash block that was under a flash command operation. 1 the dfdif ?g is cleared by writing a 1 to dfdif. writing a 0 to dfdif has no effect on dfdif. 2 0 no double bit fault detected 1 double bit fault detected or a flash array read operation returning invalid data was attempted while command running 1 the single bit fault and double bit fault ?gs are mutually exclusive for parity errors (an ecc fault occurrence can be either single fault or double fault but never both). a simultaneous access collision (flash array read operation returning invalid data attempted while command running) is indicated when both sfdif and dfdif ?gs are high. 2 there is a one cycle delay in storing the ecc dfdif and sfdif fault ?gs in this register. at least one nop is required after a ?sh memory read before checking ferstat for the occurrence of ecc errors. 0 sfdif single bit fault detect interrupt flag ?with the ignsf bit in the fcnfg register clear, the sfdif ?g indicates that a single bit fault was detected in the stored parity and data bits during a flash array read operation or that a flash array read operation returning invalid data was attempted on a flash block that was under a flash command operation. 1 the sfdif ?g is cleared by writing a 1 to sfdif. writing a 0 to sfdif has no effect on sfdif. 0 no single bit fault detected 1 single bit fault detected and corrected or a flash array read operation returning invalid data was attempted while command running offset module base + 0x0008 76543210 r fpopen rnv6 fphdis fphs[1:0] fpldis fpls[1:0] w reset f 1 1 loaded from ifr flash con?uration ?ld, during reset sequence. f 1 f 1 f 1 f 1 f 1 f 1 f 1 = unimplemented or reserved figure 27-13. flash protection register (fprot)
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 948 freescale semiconductor trying to alter data in any protected area in the p-flash memory will result in a protection violation error and the fpviol bit will be set in the fstat register. the block erase of a p-flash block is not possible if any of the p-flash sectors contained in the same p-flash block are protected. table 27-17. fprot field descriptions field description 7 fpopen flash protection operation enable ?the fpopen bit determines the protection function for program or erase operations as shown in table 27-18 for the p-flash block. 0 when fpopen is clear, the fphdis and fpldis bits de?e unprotected address ranges as speci?d by the corresponding fphs and fpls bits 1 when fpopen is set, the fphdis and fpldis bits enable protection for the address range speci?d by the corresponding fphs and fpls bits 6 rnv[6] reserved nonvolatile bit ?the rnv bit should remain in the erased state for future enhancements. 5 fphdis flash protection higher address range disable ?the fphdis bit determines whether there is a protected/unprotected area in a speci? region of the p-flash memory ending with global address 0x3_ffff. 0 protection/unprotection enabled 1 protection/unprotection disabled 4? fphs[1:0] flash protection higher address size the fphs bits determine the size of the protected/unprotected area in p-flash memory as shown in table 27-19 . the fphs bits can only be written to while the fphdis bit is set. 2 fpldis flash protection lower address range disable ?the fpldis bit determines whether there is a protected/unprotected area in a speci? region of the p-flash memory beginning with global address 0x3_8000. 0 protection/unprotection enabled 1 protection/unprotection disabled 1? fpls[1:0] flash protection lower address size the fpls bits determine the size of the protected/unprotected area in p-flash memory as shown in table 27-20 . the fpls bits can only be written to while the fpldis bit is set. table 27-18. p-flash protection function fpopen fphdis fpldis function 1 1 for range sizes, refer to table 27-19 and table 27-20 . 1 1 1 no p-flash protection 1 1 0 protected low range 1 0 1 protected high range 1 0 0 protected high and low ranges 0 1 1 full p-flash memory protected 0 1 0 unprotected low range 0 0 1 unprotected high range 0 0 0 unprotected high and low ranges
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 949 all possible p-flash protection scenarios are shown in figure 27-14 . although the protection scheme is loaded from the flash memory at global address 0x3_ff0c during the reset sequence, it can be changed by the user. the p-flash protection scheme can be used by applications requiring reprogramming in single chip mode while providing as much protection as possible if reprogramming is not required. table 27-19. p-flash protection higher address range fphs[1:0] global address range protected size 00 0x3_f800?x3_ffff 2 kbytes 01 0x3_f000?x3_ffff 4 kbytes 10 0x3_e000?x3_ffff 8 kbytes 11 0x3_c000?x3_ffff 16 kbytes table 27-20. p-flash protection lower address range fpls[1:0] global address range protected size 00 0x3_8000?x3_83ff 1 kbyte 01 0x3_8000?x3_87ff 2 kbytes 10 0x3_8000?x3_8fff 4 kbytes 11 0x3_8000?x3_9fff 8 kbytes
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 950 freescale semiconductor figure 27-14. p-flash protection scenarios 7 6 5 4 fphs[1:0] fpls[1:0] 3 2 1 0 fphs[1:0] fpls[1:0] fphdis = 1 fpldis = 1 fphdis = 1 fpldis = 0 fphdis = 0 fpldis = 1 fphdis = 0 fpldis = 0 scenario scenario unprotected region protected region with size protected region protected region with size defined by fpls defined by fphs not defined by fpls, fphs 0x3_8000 0x3_ffff 0x3_8000 0x3_ffff flash start flash start fpopen = 1 fpopen = 0
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 951 27.3.2.9.1 p-flash protection restrictions the general guideline is that p-flash protection can only be added and not removed. table 27-21 speci?s all valid transitions between p-flash protection scenarios. any attempt to write an invalid scenario to the fprot register will be ignored. the contents of the fprot register re?ct the active protection scenario. see the fphs and fpls bit descriptions for additional restrictions. 27.3.2.10 eeprom protection register (eeprot) the eeprot register de?es which eeprom sectors are protected against program and erase operations. the (unreserved) bits of the eeprot register are writable with the restriction that protection can be added but not removed. writes must increase the dps value and the dpopen bit can only be written from 1 (protection disabled) to 0 (protection enabled). if the dpopen bit is set, the state of the dps bits is irrelevant. table 27-21. p-flash protection scenario transitions from protection scenario to protection scenario 1 1 allowed transitions marked with x, see figure 27-14 for a de?ition of the scenarios. 01234567 0 xxxx 1 xx 2 xx 3 x 4 xx 5 xxxx 6 xxxx 7 xxxxxxxx offset module base + 0x0009 76543210 r dpopen 0 dps[5:0] w reset f 1 1 loaded from ifr flash con?uration ?ld, during reset sequence. 0f 1 f 1 f 1 f 1 f 1 f 1 = unimplemented or reserved figure 27-15. eeprom protection register (eeprot)
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 952 freescale semiconductor during the reset sequence, ?lds dpopen and dps of the eeprot register are loaded with the contents of the eeprom protection byte in the flash configuration field at global address 0x3_ff0d located in p-flash memory (see table 27-4 ) as indicated by reset condition f in table 27-23 . to change the eeprom protection that will be loaded during the reset sequence, the p-flash sector containing the eeprom protection byte must be unprotected, then the eeprom protection byte must be programmed. if a double bit fault is detected while reading the p-flash phrase containing the eeprom protection byte during the reset sequence, the dpopen bit will be cleared and dps bits will be set to leave the eeprom memory fully protected. trying to alter data in any protected area in the eeprom memory will result in a protection violation error and the fpviol bit will be set in the fstat register. block erase of the eeprom memory is not possible if any of the eeprom sectors are protected. table 27-22. eeprot field descriptions field description 7 dpopen eeprom protection control 0 enables eeprom memory protection from program and erase with protected address range de?ed by dps bits 1 disables eeprom memory protection from program and erase 5? dps[5:0] eeprom protection size ?the dps[5:0] bits determine the size of the protected area in the eeprom memory as shown in table 27-23 . table 27-23. eeprom protection address range dps[5:0] global address range protected size 000000 0x0_0400 ?0x0_041f 32 bytes 000001 0x0_0400 ?0x0_043f 64 bytes 000010 0x0_0400 ?0x0_045f 96 bytes 000011 0x0_0400 ?0x0_047f 128 bytes 000100 0x0_0400 ?0x0_049f 160 bytes 000101 0x0_0400 ?0x0_04bf 192 bytes the protection size goes on enlarging in step of 32 bytes, for each dps value increasing of one. . . . 111111 0x0_0400 ?0x0_0bff 2,048 bytes
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 953 27.3.2.11 flash common command object register (fccob) the fccob is an array of six words addressed via the ccobix index found in the fccobix register. byte wide reads and writes are allowed to the fccob register. 27.3.2.11.1 fccob - nvm command mode nvm command mode uses the indexed fccob register to provide a command code and its relevant parameters to the memory controller. the user ?st sets up all required fccob ?lds and then initiates the commands execution by writing a 1 to the ccif bit in the fstat register (a 1 written by the user clears the ccif command completion ?g to 0). when the user clears the ccif bit in the fstat register all fccob parameter ?lds are locked and cannot be changed by the user until the command completes (as evidenced by the memory controller returning ccif to 1). some commands return information to the fccob register array. the generic format for the fccob parameter ?lds in nvm command mode is shown in table 27-24 . the return values are available for reading after the ccif ?g in the fstat register has been returned to 1 by the memory controller. writes to the unimplemented parameter ?lds (ccobix = 110 and ccobix = 111) are ignored with reads from these ?lds returning 0x0000. table 27-24 shows the generic flash command format. the high byte of the ?st word in the ccob array contains the command code, followed by the parameters for this speci? flash command. for details on the fccob settings required by each command, see the flash command descriptions in section 27.4.6 . offset module base + 0x000a 76543210 r ccob[15:8] w reset 00000000 figure 27-16. flash common command object high register (fccobhi) offset module base + 0x000b 76543210 r ccob[7:0] w reset 00000000 figure 27-17. flash common command object low register (fccoblo) table 27-24. fccob - nvm command mode (typical usage) ccobix[2:0] byte fccob parameter fields (nvm command mode) 000 hi fcmd[7:0] de?ing flash command lo 6?0, global address [17:16] 001 hi global address [15:8] lo global address [7:0]
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 954 freescale semiconductor 27.3.2.12 flash reserved1 register (frsv1) this flash register is reserved for factory testing. all bits in the frsv1 register read 0 and are not writable. 27.3.2.13 flash reserved2 register (frsv2) this flash register is reserved for factory testing. all bits in the frsv2 register read 0 and are not writable. 27.3.2.14 flash reserved3 register (frsv3) this flash register is reserved for factory testing. 010 hi data 0 [15:8] lo data 0 [7:0] 011 hi data 1 [15:8] lo data 1 [7:0] 100 hi data 2 [15:8] lo data 2 [7:0] 101 hi data 3 [15:8] lo data 3 [7:0] offset module base + 0x000c 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 27-18. flash reserved1 register (frsv1) offset module base + 0x000d 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 27-19. flash reserved2 register (frsv2) table 27-24. fccob - nvm command mode (typical usage) ccobix[2:0] byte fccob parameter fields (nvm command mode)
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 955 all bits in the frsv3 register read 0 and are not writable. 27.3.2.15 flash reserved4 register (frsv4) this flash register is reserved for factory testing. all bits in the frsv4 register read 0 and are not writable. 27.3.2.16 flash option register (fopt) the fopt register is the flash option register. all bits in the fopt register are readable but are not writable. during the reset sequence, the fopt register is loaded from the flash nonvolatile byte in the flash con?uration ?ld at global address 0x3_ff0e located in p-flash memory (see table 27-4 ) as indicated by reset condition f in figure 27-22 . if a double bit fault is detected while reading the p-flash phrase containing the flash nonvolatile byte during the reset sequence, all bits in the fopt register will be set. offset module base + 0x000e 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 27-20. flash reserved3 register (frsv3) offset module base + 0x000f 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 27-21. flash reserved4 register (frsv4) offset module base + 0x0010 76543210 r nv[7:0] w reset f 1 1 loaded from ifr flash con?uration ?ld, during reset sequence. f 1 f 1 f 1 f 1 f 1 f 1 f 1 = unimplemented or reserved figure 27-22. flash option register (fopt)
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 956 freescale semiconductor 27.3.2.17 flash reserved5 register (frsv5) this flash register is reserved for factory testing. all bits in the frsv5 register read 0 and are not writable. 27.3.2.18 flash reserved6 register (frsv6) this flash register is reserved for factory testing. all bits in the frsv6 register read 0 and are not writable. 27.3.2.19 flash reserved7 register (frsv7) this flash register is reserved for factory testing. table 27-25. fopt field descriptions field description 7? nv[7:0] nonvolatile bits the nv[7:0] bits are available as nonvolatile bits. refer to the device user guide for proper use of the nv bits. offset module base + 0x0011 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 27-23. flash reserved5 register (frsv5) offset module base + 0x0012 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 27-24. flash reserved6 register (frsv6)
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 957 all bits in the frsv7 register read 0 and are not writable. 27.4 functional description 27.4.1 modes of operation the ftmrg64k1 module provides the modes of operation normal and special . the operating mode is determined by module-level inputs and affects the fclkdiv, fcnfg, and eeprot registers (see table 27-27 ). 27.4.2 ifr version id word the version id word is stored in the ifr at address 0x0_40b6. the contents of the word are de?ed in table 27-26 . vernum: version number. the ?st version is number 0b_0001 with both 0b_0000 and 0b_1111 meaning ?one? offset module base + 0x0013 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 27-25. flash reserved7 register (frsv7) table 27-26. ifr version id fields [15:4] [3:0] reserved vernum
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 958 freescale semiconductor 27.4.3 internal nvm resource (nvmres) ifr is an internal nvm resource readable by cpu , when nvmres is active. the ifr ?lds are shown in table 27-5 . the nvmres global address map is shown in table 27-6 . 27.4.4 flash command operations flash command operations are used to modify flash memory contents. the next sections describe: how to write the fclkdiv register that is used to generate a time base (fclk) derived from busclk for flash program and erase command operations the command write sequence used to set flash command parameters and launch execution valid flash commands available for execution, according to mcu functional mode and mcu security state. 27.4.4.1 writing the fclkdiv register prior to issuing any flash program or erase command after a reset, the user is required to write the fclkdiv register to divide busclk down to a target fclk of 1 mhz. table 27-8 shows recommended values for the fdiv ?ld based on busclk frequency. note programming or erasing the flash memory cannot be performed if the bus clock runs at less than 0.8 mhz. setting fdiv too high can destroy the flash memory due to overstress. setting fdiv too low can result in incomplete programming or erasure of the flash memory cells. when the fclkdiv register is written, the fdivld bit is set automatically. if the fdivld bit is 0, the fclkdiv register has not been written since the last reset. if the fclkdiv register has not been written, any flash program or erase command loaded during a command write sequence will not execute and the accerr bit in the fstat register will set. 27.4.4.2 command write sequence the memory controller will launch all valid flash commands entered using a command write sequence. before launching a command, the accerr and fpviol bits in the fstat register must be clear (see section 27.3.2.7 ) and the ccif ?g should be tested to determine the status of the current command write sequence. if ccif is 0, the previous command write sequence is still active, a new command write sequence cannot be started, and all writes to the fccob register are ignored.
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 959 27.4.4.2.1 de?e fccob contents the fccob parameter ?lds must be loaded with all required parameters for the flash command being executed. access to the fccob parameter ?lds is controlled via the ccobix bits in the fccobix register (see section 27.3.2.3 ). the contents of the fccob parameter ?lds are transferred to the memory controller when the user clears the ccif command completion ?g in the fstat register (writing 1 clears the ccif to 0). the ccif ?g will remain clear until the flash command has completed. upon completion, the memory controller will return ccif to 1 and the fccob register will be used to communicate any results. the ?w for a generic command write sequence is shown in figure 27-26 .
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 960 freescale semiconductor figure 27-26. generic flash command write sequence flowchart write to fccobix register write: fstat register (to launch command) clear ccif 0x80 clear accerr/fpviol 0x30 write: fstat register yes no access error and protection violation read: fstat register start check fccob accerr/ fpviol set? exit write: fclkdiv register read: fclkdiv register yes no fdiv correct? no bit polling for command completion check yes ccif set? to identify speci? command parameter to load. write to fccob register to load required command parameter. yes no more parameters? availability check results from previous command note: fclkdiv must be set after each reset read: fstat register no yes ccif set? no yes ccif set? clock divider value check read: fstat register
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 961 27.4.4.3 valid flash module commands table 27-27 present the valid flash commands, as enabled by the combination of the functional mcu mode (normal singlechip ns, special singlechip ss) with the mcu security state (unsecured, secured). special singlechip mode is selected by input mmc_ss_mode_ts2 asserted. mcu secured state is selected by input mmc_secure input asserted. + 27.4.4.4 p-flash commands table 27-28 summarizes the valid p-flash commands along with the effects of the commands on the p-flash block and other resources within the flash module. table 27-27. flash commands by mode and security state fcmd command unsecured secured ns 1 1 unsecured normal single chip mode ss 2 2 unsecured special single chip mode. ns 3 3 secured normal single chip mode. ss 4 4 secured special single chip mode. 0x01 erase verify all blocks ???? 0x02 erase verify block ???? 0x03 erase verify p-flash section ??? 0x04 read once ??? 0x06 program p-flash ??? 0x07 program once ??? 0x08 erase all blocks ?? 0x09 erase flash block ??? 0x0a erase p-flash sector ??? 0x0b unsecure flash ?? 0x0c verify backdoor access key ?? 0x0d set user margin level ??? 0x0e set field margin level ? 0x10 erase verify eeprom section ??? 0x11 program eeprom ??? 0x12 erase eeprom sector ??? table 27-28. p-flash commands fcmd command function on p-flash memory 0x01 erase verify all blocks verify that all p-flash (and eeprom) blocks are erased.
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 962 freescale semiconductor 27.4.4.5 eeprom commands table 27-29 summarizes the valid eeprom commands along with the effects of the commands on the eeprom block. 0x02 erase verify block verify that a p-flash block is erased. 0x03 erase verify p-flash section verify that a given number of words starting at the address provided are erased. 0x04 read once read a dedicated 64 byte ?ld in the nonvolatile information register in p-flash block that was previously programmed using the program once command. 0x06 program p-flash program a phrase in a p-flash block. 0x07 program once program a dedicated 64 byte ?ld in the nonvolatile information register in p-flash block that is allowed to be programmed only once. 0x08 erase all blocks erase all p-flash (and eeprom) blocks. an erase of all flash blocks is only possible when the fpldis, fphdis, and fpopen bits in the fprot register and the dpopen bit in the eeprot register are set prior to launching the command. 0x09 erase flash block erase a p-flash (or eeprom) block. an erase of the full p-flash block is only possible when fpldis, fphdis and fpopen bits in the fprot register are set prior to launching the command. 0x0a erase p-flash sector erase all bytes in a p-flash sector. 0x0b unsecure flash supports a method of releasing mcu security by erasing all p-flash (and eeprom) blocks and verifying that all p-flash (and eeprom) blocks are erased. 0x0c verify backdoor access key supports a method of releasing mcu security by verifying a set of security keys. 0x0d set user margin level speci?s a user margin read level for all p-flash blocks. 0x0e set field margin level speci?s a ?ld margin read level for all p-flash blocks (special modes only). table 27-29. eeprom commands fcmd command function on eeprom memory 0x01 erase verify all blocks verify that all eeprom (and p-flash) blocks are erased. 0x02 erase verify block verify that the eeprom block is erased. table 27-28. p-flash commands fcmd command function on p-flash memory
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 963 27.4.5 allowed simultaneous p-flash and eeprom operations only the operations marked ?k?in table 27-30 are permitted to be run simultaneously on the program flash and eeprom blocks. some operations cannot be executed simultaneously because certain hardware resources are shared by the two memories. the priority has been placed on permitting program flash reads while program and erase operations execute on the eeprom, providing read (p-flash) while write (eeprom) functionality. 0x08 erase all blocks erase all eeprom (and p-flash) blocks. an erase of all flash blocks is only possible when the fpldis, fphdis, and fpopen bits in the fprot register and the dpopen bit in the eeprot register are set prior to launching the command. 0x09 erase flash block erase a eeprom (or p-flash) block. an erase of the full eeprom block is only possible when dpopen bit in the eeprot register is set prior to launching the command. 0x0b unsecure flash supports a method of releasing mcu security by erasing all eeprom (and p-flash) blocks and verifying that all eeprom (and p-flash) blocks are erased. 0x0d set user margin level speci?s a user margin read level for the eeprom block. 0x0e set field margin level speci?s a ?ld margin read level for the eeprom block (special modes only). 0x10 erase verify eeprom section verify that a given number of words starting at the address provided are erased. 0x11 program eeprom program up to four words in the eeprom block. 0x12 erase eeprom sector erase all bytes in a sector of the eeprom block. table 27-30. allowed p-flash and eeprom simultaneous operations eeprom program flash read margin read 1 program sector erase mass erase 2 read ok ok ok margin read 1 1 a ?argin read?is any read after executing the margin setting commands ?et user margin level?or ?et field margin level?with anything but the ?ormal level speci?d. see the note on margin settings in section 27.4.6.12 and section 27.4.6.13 . program sector erase mass erase 2 2 the ?ass erase?operations are commands ?rase all blocks?and ?rase flash block ok table 27-29. eeprom commands fcmd command function on eeprom memory
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 964 freescale semiconductor 27.4.6 flash command description this section provides details of all available flash commands launched by a command write sequence. the accerr bit in the fstat register will be set during the command write sequence if any of the following illegal steps are performed, causing the command not to be processed by the memory controller: starting any command write sequence that programs or erases flash memory before initializing the fclkdiv register writing an invalid command as part of the command write sequence for additional possible errors, refer to the error handling table provided for each command if a flash block is read during execution of an algorithm (ccif = 0) on that same block, the read operation will return invalid data if both ?gs sfdif and dfdif are set. if the sfdif or dfdif ?gs were not previously set when the invalid read operation occurred, both the sfdif and dfdif ?gs will be set. if the accerr or fpviol bits are set in the fstat register, the user must clear these bits before starting any command write sequence (see section 27.3.2.7 ). caution a flash word or phrase must be in the erased state before being programmed. cumulative programming of bits within a flash word or phrase is not allowed. 27.4.6.1 erase verify all blocks command the erase verify all blocks command will verify that all p-flash and eeprom blocks have been erased. upon clearing ccif to launch the erase verify all blocks command, the memory controller will verify that the entire flash memory space is erased. the ccif ?g will set after the erase verify all blocks operation has completed. if all blocks are not erased, it means blank check failed, both mgstat bits will be set. table 27-31. erase verify all blocks command fccob requirements ccobix[2:0] fccob parameters 000 0x01 not required table 27-32. erase verify all blocks command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 000 at command launch fpviol none mgstat1 set if any errors have been encountered during the reador if blank check failed . mgstat0 set if any non-correctable errors have been encountered during the read or if blank check failed.
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 965 27.4.6.2 erase verify block command the erase verify block command allows the user to verify that an entire p-flash or eeprom block has been erased. the fccob flashblockselectioncode[1:0] bits determine which block must be veri?d. upon clearing ccif to launch the erase verify block command, the memory controller will verify that the selected p-flash or eeprom block is erased. the ccif ?g will set after the erase verify block operation has completed.if the block is not erased, it means blank check failed, both mgstat bits will be set. 27.4.6.3 erase verify p-flash section command the erase verify p-flash section command will verify that a section of code in the p-flash memory is erased. the erase verify p-flash section command de?es the starting point of the code to be veri?d and the number of phrases. table 27-33. erase verify block command fccob requirements ccobix[2:0] fccob parameters 000 0x02 flash block selection code [1:0] . see table 27-34 table 27-34. flash block selection code description selection code[1:0] flash block to be veri?d 00 eeprom 01 invalid (accerr) 10 invalid (accerr) 11 p-flash table 27-35. erase verify block command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 000 at command launch set if an invalid flashblockselectioncode[1:0] is supplied fpviol none mgstat1 set if any errors have been encountered during the read or if blank check failed. mgstat0 set if any non-correctable errors have been encountered during the read or if blank check failed.
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 966 freescale semiconductor upon clearing ccif to launch the erase verify p-flash section command, the memory controller will verify the selected section of flash memory is erased. the ccif ?g will set after the erase verify p-flash section operation has completed. if the section is not erased, it means blank check failed, both mgstat bits will be set. 27.4.6.4 read once command the read once command provides read access to a reserved 64 byte ?ld (8 phrases) located in the nonvolatile information register of p-flash. the read once ?ld is programmed using the program once command described in section 27.4.6.6 . the read once command must not be executed from the flash block containing the program once reserved ?ld to avoid code runaway. table 27-36. erase verify p-flash section command fccob requirements ccobix[2:0] fccob parameters 000 0x03 global address [17:16] of a p-flash block 001 global address [15:0] of the ?st phrase to be veri?d 010 number of phrases to be veri?d table 27-37. erase verify p-flash section command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 010 at command launch set if command not available in current mode (see table 27-27 ) set if an invalid global address [17:0] is supplied see table 27-3 ) set if a misaligned phrase address is supplied (global address [2:0] != 000) set if the requested section crosses a the p-flash address boundary fpviol none mgstat1 set if any errors have been encountered during the read or if blank check failed. mgstat0 set if any non-correctable errors have been encountered during the read or if blank check failed. table 27-38. read once command fccob requirements ccobix[2:0] fccob parameters 000 0x04 not required 001 read once phrase index (0x0000 - 0x0007) 010 read once word 0 value 011 read once word 1 value 100 read once word 2 value 101 read once word 3 value
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 967 upon clearing ccif to launch the read once command, a read once phrase is fetched and stored in the fccob indexed register. the ccif ?g will set after the read once operation has completed. valid phrase index values for the read once command range from 0x0000 to 0x0007. during execution of the read once command, any attempt to read addresses within p-flash block will return invalid data. 8 27.4.6.5 program p-flash command the program p-flash operation will program a previously erased phrase in the p-flash memory using an embedded algorithm. caution a p-flash phrase must be in the erased state before being programmed. cumulative programming of bits within a flash phrase is not allowed. upon clearing ccif to launch the program p-flash command, the memory controller will program the data words to the supplied global address and will then proceed to verify the data words read back as expected. the ccif ?g will set after the program p-flash operation has completed. table 27-39. read once command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 27-27 ) set if an invalid phrase index is supplied fpviol none mgstat1 set if any errors have been encountered during the read mgstat0 set if any non-correctable errors have been encountered during the read table 27-40. program p-flash command fccob requirements ccobix[2:0] fccob parameters 000 0x06 global address [17:16] to identify p-flash block 001 global address [15:0] of phrase location to be programmed 1 1 global address [2:0] must be 000 010 word 0 program value 011 word 1 program value 100 word 2 program value 101 word 3 program value
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 968 freescale semiconductor 27.4.6.6 program once command the program once command restricts programming to a reserved 64 byte ?ld (8 phrases) in the nonvolatile information register located in p-flash. the program once reserved ?ld can be read using the read once command as described in section 27.4.6.4 . the program once command must only be issued once since the nonvolatile information register in p-flash cannot be erased. the program once command must not be executed from the flash block containing the program once reserved ?ld to avoid code runaway. upon clearing ccif to launch the program once command, the memory controller ?st veri?s that the selected phrase is erased. if erased, then the selected phrase will be programmed and then veri?d with read back. the ccif ?g will remain clear, setting only after the program once operation has completed. the reserved nonvolatile information register accessed by the program once command cannot be erased and any attempt to program one of these phrases a second time will not be allowed. valid phrase index values for the program once command range from 0x0000 to 0x0007. during execution of the program once command, any attempt to read addresses within p-flash will return invalid data. table 27-41. program p-flash command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 101 at command launch set if command not available in current mode (see table 27-27 ) set if an invalid global address [17:0] is supplied see table 27-3 ) set if a misaligned phrase address is supplied (global address [2:0] != 000) fpviol set if the global address [17:0] points to a protected area mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation table 27-42. program once command fccob requirements ccobix[2:0] fccob parameters 000 0x07 not required 001 program once phrase index (0x0000 - 0x0007) 010 program once word 0 value 011 program once word 1 value 100 program once word 2 value 101 program once word 3 value
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 969 27.4.6.7 erase all blocks command the erase all blocks operation will erase the entire p-flash and eeprom memory space. upon clearing ccif to launch the erase all blocks command, the memory controller will erase the entire flash memory space and verify that it is erased. if the memory controller veri?s that the entire flash memory space was properly erased, security will be released. during the execution of this command (ccif=0) the user must not write to any flash module register. the ccif ?g will set after the erase all blocks operation has completed. 27.4.6.8 erase flash block command the erase flash block operation will erase all addresses in a p-flash or eeprom block. table 27-43. program once command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 101 at command launch set if command not available in current mode (see table 27-27 ) set if an invalid phrase index is supplied set if the requested phrase has already been programmed 1 1 if a program once phrase is initially programmed to 0xffff_ffff_ffff_ffff, the program once command will be allowed to execute again on that same phrase. fpviol none mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation table 27-44. erase all blocks command fccob requirements ccobix[2:0] fccob parameters 000 0x08 not required table 27-45. erase all blocks command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 000 at command launch set if command not available in current mode (see table 27-27 ) fpviol set if any area of the p-flash or eeprom memory is protected mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 970 freescale semiconductor upon clearing ccif to launch the erase flash block command, the memory controller will erase the selected flash block and verify that it is erased. the ccif ?g will set after the erase flash block operation has completed. 27.4.6.9 erase p-flash sector command the erase p-flash sector operation will erase all addresses in a p-flash sector. upon clearing ccif to launch the erase p-flash sector command, the memory controller will erase the selected flash sector and then verify that it is erased. the ccif ?g will be set after the erase p-flash sector operation has completed. table 27-46. erase flash block command fccob requirements ccobix[2:0] fccob parameters 000 0x09 global address [17:16] to identify flash block 001 global address [15:0] in flash block to be erased table 27-47. erase flash block command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 27-27 ) set if an invalid global address [17:16] is supplied set if the supplied p-flash address is not phrase-aligned or if the eeprom address is not word-aligned fpviol set if an area of the selected flash block is protected mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation table 27-48. erase p-flash sector command fccob requirements ccobix[2:0] fccob parameters 000 0x0a global address [17:16] to identify p-flash block to be erased 001 global address [15:0] anywhere within the sector to be erased. refer to section 27.1.2.1 for the p-flash sector size.
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 971 27.4.6.10 unsecure flash command the unsecure flash command will erase the entire p-flash and eeprom memory space and, if the erase is successful, will release security. upon clearing ccif to launch the unsecure flash command, the memory controller will erase the entire p-flash and eeprom memory space and verify that it is erased. if the memory controller veri?s that the entire flash memory space was properly erased, security will be released. if the erase verify is not successful, the unsecure flash operation sets mgstat1 and terminates without changing the security state. during the execution of this command (ccif=0) the user must not write to any flash module register. the ccif ?g is set after the unsecure flash operation has completed. 27.4.6.11 verify backdoor access key command the verify backdoor access key command will only execute if it is enabled by the keyen bits in the fsec register (see table 27-10 ). the verify backdoor access key command releases security if user-supplied keys match those stored in the flash security bytes of the flash con?uration ?ld (see table 27-49. erase p-flash sector command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 27-27 ) set if an invalid global address [17:16] is supplied see table 27-3 ) set if a misaligned phrase address is supplied (global address [2:0] != 000) fpviol set if the selected p-flash sector is protected mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation table 27-50. unsecure flash command fccob requirements ccobix[2:0] fccob parameters 000 0x0b not required table 27-51. unsecure flash command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 000 at command launch set if command not available in current mode (see table 27-27 ) fpviol set if any area of the p-flash or eeprom memory is protected mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 972 freescale semiconductor table 27-4 ). the verify backdoor access key command must not be executed from the flash block containing the backdoor comparison key to avoid code runaway. upon clearing ccif to launch the verify backdoor access key command, the memory controller will check the fsec keyen bits to verify that this command is enabled. if not enabled, the memory controller sets the accerr bit in the fstat register and terminates. if the command is enabled, the memory controller compares the key provided in fccob to the backdoor comparison key in the flash con?uration ?ld with key 0 compared to 0x3_ff00, etc. if the backdoor keys match, security will be released. if the backdoor keys do not match, security is not released and all future attempts to execute the verify backdoor access key command are aborted (set accerr) until a reset occurs. the ccif flag is set after the verify backdoor access key operation has completed. 27.4.6.12 set user margin level command the set user margin level command causes the memory controller to set the margin level for future read operations of the p-flash or eeprom block. table 27-52. verify backdoor access key command fccob requirements ccobix[2:0] fccob parameters 000 0x0c not required 001 key 0 010 key 1 011 key 2 100 key 3 table 27-53. verify backdoor access key command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 100 at command launch set if an incorrect backdoor key is supplied set if backdoor key access has not been enabled (keyen[1:0] != 10, see section 27.3.2.2 ) set if the backdoor key has mismatched since the last reset fpviol none mgstat1 none mgstat0 none table 27-54. set user margin level command fccob requirements ccobix[2:0] fccob parameters 000 0x0d flash block selection code [1:0] . see table 27-34 001 margin level setting.
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 973 upon clearing ccif to launch the set user margin level command, the memory controller will set the user margin level for the targeted block and then set the ccif ?g. note when the eeprom block is targeted, the eeprom user margin levels are applied only to the eeprom reads. however, when the p-flash block is targeted, the p-flash user margin levels are applied to both p-flash and eeprom reads. it is not possible to apply user margin levels to the p-flash block only. valid margin level settings for the set user margin level command are de?ed in table 27-55 . note user margin levels can be used to check that flash memory contents have adequate margin for normal level read operations. if unexpected results are encountered when checking flash memory contents at user margin levels, a potential loss of information has been detected. table 27-55. valid set user margin level settings ccob (ccobix=001) level description 0x0000 return to normal level 0x0001 user margin-1 level 1 1 read margin to the erased state 0x0002 user margin-0 level 2 2 read margin to the programmed state table 27-56. set user margin level command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 27-27 ) set if an invalid flashblockselectioncode[1:0] is supplied (see table 27-34 ) set if an invalid margin level setting is supplied fpviol none mgstat1 none mgstat0 none
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 974 freescale semiconductor 27.4.6.13 set field margin level command the set field margin level command, valid in special modes only, causes the memory controller to set the margin level speci?d for future read operations of the p-flash or eeprom block. upon clearing ccif to launch the set field margin level command, the memory controller will set the ?ld margin level for the targeted block and then set the ccif ?g. note when the eeprom block is targeted, the eeprom ?ld margin levels are applied only to the eeprom reads. however, when the p-flash block is targeted, the p-flash ?ld margin levels are applied to both p-flash and eeprom reads. it is not possible to apply ?ld margin levels to the p-flash block only. valid margin level settings for the set field margin level command are de?ed in table 27-58 . table 27-57. set field margin level command fccob requirements ccobix[2:0] fccob parameters 000 0x0e flash block selection code [1:0] . see table 27-34 001 margin level setting. table 27-58. valid set field margin level settings ccob (ccobix=001) level description 0x0000 return to normal level 0x0001 user margin-1 level 1 1 read margin to the erased state 0x0002 user margin-0 level 2 2 read margin to the programmed state 0x0003 field margin-1 level 1 0x0004 field margin-0 level 2
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 975 caution field margin levels must only be used during verify of the initial factory programming. note field margin levels can be used to check that flash memory contents have adequate margin for data retention at the normal level setting. if unexpected results are encountered when checking flash memory contents at ?ld margin levels, the flash memory contents should be erased and reprogrammed. 27.4.6.14 erase verify eeprom section command the erase verify eeprom section command will verify that a section of code in the eeprom is erased. the erase verify eeprom section command de?es the starting point of the data to be veri?d and the number of words. upon clearing ccif to launch the erase verify eeprom section command, the memory controller will verify the selected section of eeprom memory is erased. the ccif ?g will set after the erase verify eeprom section operation has completed. if the section is not erased, it means blank check failed, both mgstat bits will be set. table 27-59. set field margin level command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 27-27 ) set if an invalid flashblockselectioncode[1:0] is supplied (see table 27-34 ) set if an invalid margin level setting is supplied fpviol none mgstat1 none mgstat0 none table 27-60. erase verify eeprom section command fccob requirements ccobix[2:0] fccob parameters 000 0x10 global address [17:16] to identify the eeprom block 001 global address [15:0] of the ?st word to be veri?d 010 number of words to be veri?d
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 976 freescale semiconductor 27.4.6.15 program eeprom command the program eeprom operation programs one to four previously erased words in the eeprom block. the program eeprom operation will con?m that the targeted location(s) were successfully programmed upon completion. caution a flash word must be in the erased state before being programmed. cumulative programming of bits within a flash word is not allowed. upon clearing ccif to launch the program eeprom command, the user-supplied words will be transferred to the memory controller and be programmed if the area is unprotected. the ccobix index value at program eeprom command launch determines how many words will be programmed in the eeprom block. the ccif ?g is set when the operation has completed. table 27-61. erase verify eeprom section command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 010 at command launch set if command not available in current mode (see table 27-27 ) set if an invalid global address [17:0] is supplied set if a misaligned word address is supplied (global address [0] != 0) set if the requested section breaches the end of the eeprom block fpviol none mgstat1 set if any errors have been encountered during the read or if blank check failed. mgstat0 set if any non-correctable errors have been encountered during the read or if blank check failed. table 27-62. program eeprom command fccob requirements ccobix[2:0] fccob parameters 000 0x11 global address [17:16] to identify the eeprom block 001 global address [15:0] of word to be programmed 010 word 0 program value 011 word 1 program value, if desired 100 word 2 program value, if desired 101 word 3 program value, if desired
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 977 27.4.6.16 erase eeprom sector command the erase eeprom sector operation will erase all addresses in a sector of the eeprom block. upon clearing ccif to launch the erase eeprom sector command, the memory controller will erase the selected flash sector and verify that it is erased. the ccif ?g will set after the erase eeprom sector operation has completed. table 27-63. program eeprom command error handling register error bit error condition fstat accerr set if ccobix[2:0] < 010 at command launch set if ccobix[2:0] > 101 at command launch set if command not available in current mode (see table 27-27 ) set if an invalid global address [17:0] is supplied set if a misaligned word address is supplied (global address [0] != 0) set if the requested group of words breaches the end of the eeprom block fpviol set if the selected area of the eeprom memory is protected mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation table 27-64. erase eeprom sector command fccob requirements ccobix[2:0] fccob parameters 000 0x12 global address [17:16] to identify eeprom block 001 global address [15:0] anywhere within the sector to be erased. see section 27.1.2.2 for eeprom sector size. table 27-65. erase eeprom sector command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 27-27 ) set if an invalid global address [17:0] is suppliedsee table 27-3 ) set if a misaligned word address is supplied (global address [0] != 0) fpviol set if the selected area of the eeprom memory is protected mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 978 freescale semiconductor 27.4.7 interrupts the flash module can generate an interrupt when a flash command operation has completed or when a flash command operation has detected an ecc fault. note vector addresses and their relative interrupt priority are determined at the mcu level. 27.4.7.1 description of flash interrupt operation the flash module uses the ccif ?g in combination with the ccie interrupt enable bit to generate the flash command interrupt request. the flash module uses the dfdif and sfdif ?gs in combination with the dfdie and sfdie interrupt enable bits to generate the flash error interrupt request. for a detailed description of the register bits involved, refer to section 27.3.2.5, ?lash configuration register (fcnfg) ? section 27.3.2.6, ?lash error configuration register (fercnfg) ? section 27.3.2.7, ?lash status register (fstat) ? and section 27.3.2.8, ?lash error status register (ferstat) ? the logic used for generating the flash module interrupts is shown in figure 27-27 . figure 27-27. flash module interrupts implementation table 27-66. flash interrupt sources interrupt source interrupt flag local enable global (ccr) mask flash command complete ccif (fstat register) ccie (fcnfg register) i bit ecc double bit fault on flash read dfdif (ferstat register) dfdie (fercnfg register) i bit ecc single bit fault on flash read sfdif (ferstat register) sfdie (fercnfg register) i bit flash error interrupt request ccif ccie dfdif dfdie sfdif sfdie flash command interrupt request
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 979 27.4.8 wait mode the flash module is not affected if the mcu enters wait mode. the flash module can recover the mcu from wait via the ccif interrupt (see section 27.4.7, ?nterrupts ). 27.4.9 stop mode if a flash command is active (ccif = 0) when the mcu requests stop mode, the current flash operation will be completed before the mcu is allowed to enter stop mode. 27.5 security the flash module provides security information to the mcu. the flash security state is de?ed by the sec bits of the fsec register (see table 27-11 ). during reset, the flash module initializes the fsec register using data read from the security byte of the flash con?uration ?ld at global address 0x3_ff0f. the security state out of reset can be permanently changed by programming the security byte assuming that the mcu is starting from a mode where the necessary p-flash erase and program commands are available and that the upper region of the p-flash is unprotected. if the flash security byte is successfully programmed, its new value will take affect after the next mcu reset. the following subsections describe these security-related subjects: unsecuring the mcu using backdoor key access unsecuring the mcu in special single chip mode using bdm mode and security effects on flash command availability 27.5.1 unsecuring the mcu using backdoor key access the mcu may be unsecured by using the backdoor key access feature which requires knowledge of the contents of the backdoor keys (four 16-bit words programmed at addresses 0x3_ff00-0x3_ff07). if the keyen[1:0] bits are in the enabled state (see section 27.3.2.2 ), the verify backdoor access key command (see section 27.4.6.11 ) allows the user to present four prospective keys for comparison to the keys stored in the flash memory via the memory controller. if the keys presented in the verify backdoor access key command match the backdoor keys stored in the flash memory, the sec bits in the fsec register (see table 27-11 ) will be changed to unsecure the mcu. key values of 0x0000 and 0xffff are not permitted as backdoor keys. while the verify backdoor access key command is active, p-flash memory and eeprom memory will not be available for read access and will return invalid data.
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 980 freescale semiconductor the user code stored in the p-flash memory must have a method of receiving the backdoor keys from an external stimulus. this external stimulus would typically be through one of the on-chip serial ports. if the keyen[1:0] bits are in the enabled state (see section 27.3.2.2 ), the mcu can be unsecured by the backdoor key access sequence described below: 1. follow the command sequence for the verify backdoor access key command as explained in section 27.4.6.11 2. if the verify backdoor access key command is successful, the mcu is unsecured and the sec[1:0] bits in the fsec register are forced to the unsecure state of 10 the verify backdoor access key command is monitored by the memory controller and an illegal key will prohibit future use of the verify backdoor access key command. a reset of the mcu is the only method to re-enable the verify backdoor access key command. the security as de?ed in the flash security byte (0x3_ff0f) is not changed by using the verify backdoor access key command sequence. the backdoor keys stored in addresses 0x3_ff00-0x3_ff07 are unaffected by the verify backdoor access key command sequence. the verify backdoor access key command sequence has no effect on the program and erase protections de?ed in the flash protection register, fprot. after the backdoor keys have been correctly matched, the mcu will be unsecured. after the mcu is unsecured, the sector containing the flash security byte can be erased and the flash security byte can be reprogrammed to the unsecure state, if desired. in the unsecure state, the user has full control of the contents of the backdoor keys by programming addresses 0x3_ff00-0x3_ff07 in the flash con?uration ?ld. 27.5.2 unsecuring the mcu in special single chip mode using bdm a secured mcu can be unsecured in special single chip mode by using the following method to erase the p-flash and eeprom memory: 1. reset the mcu into special single chip mode 2. delay while the bdm executes the erase verify all blocks command write sequence to check if the p-flash and eeprom memories are erased 3. send bdm commands to disable protection in the p-flash and eeprom memory 4. execute the erase all blocks command write sequence to erase the p-flash and eeprom memory. alternatively the unsecure flash command can be executed, if so the steps 5 and 6 below are skeeped. 5. after the ccif ?g sets to indicate that the erase all blocks operation has completed, reset the mcu into special single chip mode 6. delay while the bdm executes the erase verify all blocks command write sequence to verify that the p-flash and eeprom memory are erased if the p-flash and eeprom memory are veri?d as erased, the mcu will be unsecured. all bdm commands will now be enabled and the flash security byte may be programmed to the unsecure state by continuing with the following steps: 7. send bdm commands to execute the program p-flash command write sequence to program the flash security byte to the unsecured state
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 981 8. reset the mcu 27.5.3 mode and security effects on flash command availability the availability of flash module commands depends on the mcu operating mode and security state as shown in table 27-27 . 27.6 initialization on each system reset the ?sh module executes an initialization sequence which establishes initial values for the flash block con?uration parameters, the fprot and eeprot protection registers, and the fopt and fsec registers. the initialization routine reverts to built-in default values that leave the module in a fully protected and secured state if errors are encountered during execution of the reset sequence. if a double bit fault is detected during the reset sequence, both mgstat bits in the fstat register will be set. ccif is cleared throughout the initialization sequence. the flash module holds off all cpu access for a portion of the initialization sequence. flash reads are allowed once the hold is removed. completion of the initialization sequence is marked by setting ccif high which enables user commands. if a reset occurs while any flash command is in progress, that command will be immediately aborted. the state of the word being programmed or the sector/block being erased is not guaranteed.
64 kbyte flash module (s12ftmrg64k1v1) mc9s12g family reference manual, rev.1.23 982 freescale semiconductor
mc9s12g family reference manual, rev.1.23 freescale semiconductor 983 chapter 28 96 kbyte flash module (s12ftmrg96k1v1) 28.1 introduction the ftmrg96k1 module implements the following: 96kbytes of p-flash (program flash) memory 3 kbytes of eeprom memory the flash memory is ideal for single-supply applications allowing for ?ld reprogramming without requiring external high voltage sources for program or erase operations. the flash module includes a memory controller that executes commands to modify flash memory contents. the user interface to the memory controller consists of the indexed flash common command object (fccob) register which is written to with the command, global address, data, and any required command parameters. the memory controller must complete the execution of a command before the fccob register can be written to with a new command. caution a flash word or phrase must be in the erased state before being programmed. cumulative programming of bits within a flash word or phrase is not allowed. table 28-1. revision history revision number revision date sections affected description of changes v01.04 17 jun 2010 28.4.6.1/28-101 6 28.4.6.2/28-101 7 28.4.6.3/28-101 8 28.4.6.14/28-10 27 clarify erase verify commands descriptions related to the bits mgstat[1:0] of the register fstat. v01.05 20 aug 2010 28.4.6.2/28-101 7 28.4.6.12/28-10 24 28.4.6.13/28-10 26 updated description of the commands rd1blk, mloadu and mloadf rev.1.23 31 jan 2011 28.3.2.9/28-999 updated description of protection on section 28.3.2.9
mc9s12g family reference manual, rev.1.23 freescale semiconductor 984 the flash memory may be read as bytes and aligned words. read access time is one bus cycle for bytes and aligned words. for misaligned words access, the cpu has to perform twice the byte read access command. for flash memory, an erased bit reads 1 and a programmed bit reads 0. it is possible to read from p-flash memory while some commands are executing on eeprom memory. it is not possible to read from eeprom memory while a command is executing on p-flash memory. simultaneous p-flash and eeprom operations are discussed in section 28.4.5 . both p-flash and eeprom memories are implemented with error correction codes (ecc) that can resolve single bit faults and detect double bit faults. for p-flash memory, the ecc implementation requires that programming be done on an aligned 8 byte basis (a flash phrase). since p-flash memory is always read by half-phrase, only one single bit fault in an aligned 4 byte half-phrase containing the byte or word accessed will be corrected. 28.1.1 glossary command write sequence ?an mcu instruction sequence to execute built-in algorithms (including program and erase) on the flash memory. eeprom memory ?the eeprom memory constitutes the nonvolatile memory store for data. eeprom sector ?the eeprom sector is the smallest portion of the eeprom memory that can be erased. the eeprom sector consists of 4 bytes. nvm command mode an nvm mode using the cpu to setup the fccob register to pass parameters required for flash command execution. phrase ?an aligned group of four 16-bit words within the p-flash memory. each phrase includes two sets of aligned double words with each set including 7 ecc bits for single bit fault correction and double bit fault detection within each double word. p-flash memory the p-flash memory constitutes the main nonvolatile memory store for applications. p-flash sector ?the p-flash sector is the smallest portion of the p-flash memory that can be erased. each p-flash sector contains 512 bytes. program ifr ?nonvolatile information register located in the p-flash block that contains the version id, and the program once ?ld. 28.1.2 features 28.1.2.1 p-flash features 96 kbytes of p-flash memory composed of one 96 kbyte flash block divided into 192 sectors of 512 bytes
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 985 single bit fault correction and double bit fault detection within a 32-bit double word during read operations automated program and erase algorithm with verify and generation of ecc parity bits fast sector erase and phrase program operation ability to read the p-flash memory while programming a word in the eeprom memory flexible protection scheme to prevent accidental program or erase of p-flash memory 28.1.2.2 eeprom features 3 kbytes of eeprom memory composed of one 3 kbyte flash block divided into 768 sectors of 4 bytes single bit fault correction and double bit fault detection within a word during read operations automated program and erase algorithm with verify and generation of ecc parity bits fast sector erase and word program operation protection scheme to prevent accidental program or erase of eeprom memory ability to program up to four words in a burst sequence 28.1.2.3 other flash module features no external high-voltage power supply required for flash memory program and erase operations interrupt generation on flash command completion and flash error detection security mechanism to prevent unauthorized access to the flash memory 28.1.3 block diagram the block diagram of the flash module is shown in figure 28-1 .
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 986 freescale semiconductor figure 28-1. ftmrg96k1 block diagram 28.2 external signal description the flash module contains no signals that connect off-chip. bus clock divider clock command interrupt request fclk protection security registers flash interface 16bit internal bus sector 0 sector 1 sector 191 24kx39 p-flash error interrupt request cpu 1.5kx22 sector 0 sector 1 sector 767 eeprom memory controller
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 987 28.3 memory map and registers this section describes the memory map and registers for the flash module. read data from unimplemented memory space in the flash module is unde?ed. write access to unimplemented or reserved memory space in the flash module will be ignored by the flash module. caution writing to the flash registers while a flash command is executing (that is indicated when the value of ?g ccif reads as ?? is not allowed. if such action is attempted the write operation will not change the register value. writing to the flash registers is allowed when the flash is not busy executing commands (ccif = 1) and during initialization right after reset, despite the value of ?g ccif in that case (refer to section 28.6 for a complete description of the reset sequence). . 28.3.1 module memory map the s12 architecture places the p-flash memory between global addresses 0x2_8000 and 0x3_ffff as shown in table 28-3 .the p-flash memory map is shown in figure 28-2 . table 28-2. ftmrg memory map global address (in bytes) size (bytes) description 0x0_0000 - 0x0_03ff 1,024 register space 0x0_0400 ?0x0_0fff 3,072 eeprom memory 0x0_1000 ?0x0_13ff 1,024 ftmrg reserved area 0x0_4000 ?0x0_7fff 16,284 nvmres 1 =1 : nvm resource area (see figure 28-3 ) 1 see nvmres description in section 28.4.3 0x2_0000 ?0x2_7fff 32,767 ftmrg reserved area 0x2_8000 ?0x3_ffff 98,304 p-flash memory
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 988 freescale semiconductor the fprot register, described in section 28.3.2.9 , can be set to protect regions in the flash memory from accidental program or erase. three separate memory regions, one growing upward from global address 0x3_8000 in the flash memory (called the lower region), one growing downward from global address 0x3_ffff in the flash memory (called the higher region), and the remaining addresses in the flash memory, can be activated for protection. the flash memory addresses covered by these protectable regions are shown in the p-flash memory map. the higher address region is mainly targeted to hold the boot loader code since it covers the vector space. default protection settings as well as security information that allows the mcu to restrict access to the flash module are stored in the flash con?uration ?ld as described in table 28-4 . table 28-3. p-flash memory addressing global address size (bytes) description 0x2_8000 ?0x3_ffff 96 k p-flash block contains flash con?uration field (see table 28-4 ) table 28-4. flash con?uration field global address size (bytes) description 0x3_ff00-0x3_ff07 8 backdoor comparison key refer to section 28.4.6.11, ?erify backdoor access key command , and section 28.5.1, ?nsecuring the mcu using backdoor key access 0x3_ff08-0x3_ff0b 1 1 0x3ff08-0x3_ff0f form a flash phrase and must be programmed in a single command write sequence. each byte in the 0x3_ff08 - 0x3_ff0b reserved ?ld should be programmed to 0xff. 4 reserved 0x3_ff0c 1 1 p-flash protection byte . refer to section 28.3.2.9, ?-flash protection register (fprot) 0x3_ff0d 1 1 eeprom protection byte . refer to section 28.3.2.10, ?eprom protection register (eeprot) 0x3_ff0e 1 1 flash nonvolatile byte refer to section 28.3.2.16, ?lash option register (fopt) 0x3_ff0f 1 1 flash security byte refer to section 28.3.2.2, ?lash security register (fsec)
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 989 figure 28-2. p-flash memory map table 28-5. program ifr fields global address size (bytes) field description 0x0_4000 ?0x0_4007 8 reserved 0x0_4008 ?0x0_40b5 174 reserved 0x0_40b6 ?0x0_40b7 2 version id 1 1 used to track ?mware patch versions, see section 28.4.2 0x0_40b8 ?0x0_40bf 8 reserved 0x0_40c0 ?0x0_40ff 64 program once field refer to section 28.4.6.6, ?rogram once command flash con?uration field 0x3_c000 flash protected/unprotected lower region 1, 2, 4, 8 kbytes 0x3_8000 0x3_9000 0x3_8400 0x3_8800 0x3_a000 p-flash end = 0x3_ffff 0x3_f800 0x3_f000 0x3_e000 flash protected/unprotected higher region 2, 4, 8, 16 kbytes flash protected/unprotected region 8 kbytes (up to 29 kbytes) 16 bytes (0x3_ff00 - 0x3_ff0f) flash protected/unprotected region 64 kbytes p-flash start = 0x2_8000 protection protection protection movable end fixed end fixed end
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 990 freescale semiconductor figure 28-3. memory controller resource memory map (nvmres=1) 28.3.2 register descriptions the flash module contains a set of 20 control and status registers located between flash module base + 0x0000 and 0x0013. in the case of the writable registers, the write accesses are forbidden during fash command execution (for more detail, see caution note in section 28.3 ). table 28-6. memory controller resource fields (nvmres 1 =1) 1 nvmres - see section 28.4.3 for nvmres (nvm resource) detail. global address size (bytes) description 0x0_4000 ?0x040ff 256 p-flash ifr (see table 28-5 ) 0x0_4100 ?0x0_41ff 256 reserved. 0x0_4200 ?0x0_57ff reserved 0x0_5800 ?0x0_59ff 512 reserved 0x0_5a00 ?0x0_5fff 1,536 reserved 0x0_6000 ?0x0_6bff 3,072 reserved 0x0_6c00 ?0x0_7fff 5,120 reserved p-flash ifr 1 kbyte (nvmres=1) 0x0_4000 ram end = 0x0_59ff ram start = 0x0_5800 reserved 5120 bytes reserved 4608 bytes 0x0_6c00 0x0_7fff 0x0_4400 reserved 5k bytes reserved 512 bytes
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 991 a summary of the flash module registers is given in figure 28-4 with detailed descriptions in the following subsections. address & name 76543210 0x0000 fclkdiv r fdivld fdivlck fdiv5 fdiv4 fdiv3 fdiv2 fdiv1 fdiv0 w 0x0001 fsec r keyen1 keyen0 rnv5 rnv4 rnv3 rnv2 sec1 sec0 w 0x0002 fccobix r0 0 0 0 0 ccobix2 ccobix1 ccobix0 w 0x0003 frsv0 r00000000 w 0x0004 fcnfg r ccie 00 ignsf 00 fdfd fsfd w 0x0005 fercnfg r0 0 0 0 0 0 dfdie sfdie w 0x0006 fstat r ccif 0 accerr fpviol mgbusy rsvd mgstat1 mgstat0 w 0x0007 ferstat r0 0 0 0 0 0 dfdif sfdif w 0x0008 fprot r fpopen rnv6 fphdis fphs1 fphs0 fpldis fpls1 fpls0 w 0x0009 eeprot r dpopen dps6 dps5 dps4 dps3 dps2 dps1 dps0 w 0x000a fccobhi r ccob15 ccob14 ccob13 ccob12 ccob11 ccob10 ccob9 ccob8 w 0x000b fccoblo r ccob7 ccob6 ccob5 ccob4 ccob3 ccob2 ccob1 ccob0 w 0x000c frsv1 r00000000 w figure 28-4. ftmrg96k1 register summary
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 992 freescale semiconductor 28.3.2.1 flash clock divider register (fclkdiv) the fclkdiv register is used to control timed events in program and erase algorithms. all bits in the fclkdiv register are readable, bit 7 is not writable, bit 6 is write-once-hi and controls the writability of the fdiv ?ld in normal mode. in special mode, bits 6-0 are writable any number of times but bit 7 remains unwritable. 0x000d frsv2 r00000000 w 0x000e frsv3 r00000000 w 0x000f frsv4 r00000000 w 0x0010 fopt r nv7 nv6 nv5 nv4 nv3 nv2 nv1 nv0 w 0x0011 frsv5 r00000000 w 0x0012 frsv6 r00000000 w 0x0013 frsv7 r00000000 w = unimplemented or reserved offset module base + 0x0000 76543210 r fdivld fdivlck fdiv[5:0] w reset 00000000 = unimplemented or reserved figure 28-5. flash clock divider register (fclkdiv) address & name 76543210 figure 28-4. ftmrg96k1 register summary (continued)
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 993 caution the fclkdiv register should never be written while a flash command is executing (ccif=0). table 28-7. fclkdiv field descriptions field description 7 fdivld clock divider loaded 0 fclkdiv register has not been written since the last reset 1 fclkdiv register has been written since the last reset 6 fdivlck clock divider locked 0 fdiv ?ld is open for writing 1 fdiv value is locked and cannot be changed. once the lock bit is set high, only reset can clear this bit and restore writability to the fdiv ?ld in normal mode. 5? fdiv[5:0] clock divider bits fdiv[5:0] must be set to effectively divide busclk down to 1 mhz to control timed events during flash program and erase algorithms. table 28-8 shows recommended values for fdiv[5:0] based on the busclk frequency. please refer to section 28.4.4, ?lash command operations , for more information. table 28-8. fdiv values for various busclk frequencies busclk frequency (mhz) fdiv[5:0] busclk frequency (mhz) fdiv[5:0] min 1 1 busclk is greater than this value. max 2 2 busclk is less than or equal to this value. min 1 max 2 1.0 1.6 0x00 16.6 17.6 0x10 1.6 2.6 0x01 17.6 18.6 0x11 2.6 3.6 0x02 18.6 19.6 0x12 3.6 4.6 0x03 19.6 20.6 0x13 4.6 5.6 0x04 20.6 21.6 0x14 5.6 6.6 0x05 21.6 22.6 0x15 6.6 7.6 0x06 22.6 23.6 0x16 7.6 8.6 0x07 23.6 24.6 0x17 8.6 9.6 0x08 24.6 25.6 0x18 9.6 10.6 0x09 10.6 11.6 0x0a 11.6 12.6 0x0b 12.6 13.6 0x0c 13.6 14.6 0x0d 14.6 15.6 0x0e 15.6 16.6 0x0f
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 994 freescale semiconductor 28.3.2.2 flash security register (fsec) the fsec register holds all bits associated with the security of the mcu and flash module. all bits in the fsec register are readable but not writable. during the reset sequence, the fsec register is loaded with the contents of the flash security byte in the flash con?uration ?ld at global address 0x3_ff0f located in p-flash memory (see table 28-4 ) as indicated by reset condition f in figure 28-6 . if a double bit fault is detected while reading the p-flash phrase containing the flash security byte during the reset sequence, all bits in the fsec register will be set to leave the flash module in a secured state with backdoor key access disabled. offset module base + 0x0001 76543210 r keyen[1:0] rnv[5:2] sec[1:0] w reset f 1 1 loaded from ifr flash con?uration ?ld, during reset sequence. f 1 f 1 f 1 f 1 f 1 f 1 f 1 = unimplemented or reserved figure 28-6. flash security register (fsec) table 28-9. fsec field descriptions field description 7? keyen[1:0] backdoor key security enable bits the keyen[1:0] bits de?e the enabling of backdoor key access to the flash module as shown in table 28-10 . 5? rnv[5:2] reserved nonvolatile bits ?the rnv bits should remain in the erased state for future enhancements. 1? sec[1:0] flash security bits ?the sec[1:0] bits de?e the security state of the mcu as shown in table 28-11 . if the flash module is unsecured using backdoor key access, the sec bits are forced to 10. table 28-10. flash keyen states keyen[1:0] status of backdoor key access 00 disabled 01 disabled 1 1 preferred keyen state to disable backdoor key access. 10 enabled 11 disabled
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 995 the security function in the flash module is described in section 28.5 . 28.3.2.3 flash ccob index register (fccobix) the fccobix register is used to index the fccob register for flash memory operations. ccobix bits are readable and writable while remaining bits read 0 and are not writable. 28.3.2.4 flash reserved0 register (frsv0) this flash register is reserved for factory testing. all bits in the frsv0 register read 0 and are not writable. table 28-11. flash security states sec[1:0] status of security 00 secured 01 secured 1 1 preferred sec state to set mcu to secured state. 10 unsecured 11 secured offset module base + 0x0002 76543210 r00000 ccobix[2:0] w reset 00000000 = unimplemented or reserved figure 28-7. fccob index register (fccobix) table 28-12. fccobix field descriptions field description 2? ccobix[1:0] common command register index the ccobix bits are used to select which word of the fccob register array is being read or written to. see 28.3.2.11 flash common command object register (fccob), for more details. offset module base + 0x000c 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 28-8. flash reserved0 register (frsv0)
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 996 freescale semiconductor 28.3.2.5 flash con?uration register (fcnfg) the fcnfg register enables the flash command complete interrupt and forces ecc faults on flash array read access from the cpu. ccie, ignsf, fdfd, and fsfd bits are readable and writable while remaining bits read 0 and are not writable. 28.3.2.6 flash error con?uration register (fercnfg) the fercnfg register enables the flash error interrupts for the ferstat ?gs. offset module base + 0x0004 76543210 r ccie 00 ignsf 00 fdfd fsfd w reset 00000000 = unimplemented or reserved figure 28-9. flash con?uration register (fcnfg) table 28-13. fcnfg field descriptions field description 7 ccie command complete interrupt enable ?the ccie bit controls interrupt generation when a flash command has completed. 0 command complete interrupt disabled 1 an interrupt will be requested whenever the ccif ?g in the fstat register is set (see section 28.3.2.7 ) 4 ignsf ignore single bit fault ?the ignsf controls single bit fault reporting in the ferstat register (see section 28.3.2.8 ). 0 all single bit faults detected during array reads are reported 1 single bit faults detected during array reads are not reported and the single bit fault interrupt will not be generated 1 fdfd force double bit fault detect the fdfd bit allows the user to simulate a double bit fault during flash array read operations and check the associated interrupt routine. the fdfd bit is cleared by writing a 0 to fdfd. 0 flash array read operations will set the dfdif ?g in the ferstat register only if a double bit fault is detected 1 any flash array read operation will force the dfdif ?g in the ferstat register to be set (see section 28.3.2.7 ) and an interrupt will be generated as long as the dfdie interrupt enable in the fercnfg register is set (see section 28.3.2.6 ) 0 fsfd force single bit fault detect the fsfd bit allows the user to simulate a single bit fault during flash array read operations and check the associated interrupt routine. the fsfd bit is cleared by writing a 0 to fsfd. 0 flash array read operations will set the sfdif ?g in the ferstat register only if a single bit fault is detected 1 flash array read operation will force the sfdif ?g in the ferstat register to be set (see section 28.3.2.7 ) and an interrupt will be generated as long as the sfdie interrupt enable in the fercnfg register is set (see section 28.3.2.6 )
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 997 all assigned bits in the fercnfg register are readable and writable. 28.3.2.7 flash status register (fstat) the fstat register reports the operational status of the flash module. ccif, accerr, and fpviol bits are readable and writable, mgbusy and mgstat bits are readable but not writable, while remaining bits read 0 and are not writable. offset module base + 0x0005 76543210 r000000 dfdie sfdie w reset 00000000 = unimplemented or reserved figure 28-10. flash error con?uration register (fercnfg) table 28-14. fercnfg field descriptions field description 1 dfdie double bit fault detect interrupt enable the dfdie bit controls interrupt generation when a double bit fault is detected during a flash block read operation. 0 dfdif interrupt disabled 1 an interrupt will be requested whenever the dfdif ?g is set (see section 28.3.2.8 ) 0 sfdie single bit fault detect interrupt enable the sfdie bit controls interrupt generation when a single bit fault is detected during a flash block read operation. 0 sfdif interrupt disabled whenever the sfdif ?g is set (see section 28.3.2.8 ) 1 an interrupt will be requested whenever the sfdif ?g is set (see section 28.3.2.8 ) offset module base + 0x0006 76543210 r ccif 0 accerr fpviol mgbusy rsvd mgstat[1:0] w reset 1000000 1 1 reset value can deviate from the value shown if a double bit fault is detected during the reset sequence (see section 28.6 ). 0 1 = unimplemented or reserved figure 28-11. flash status register (fstat)
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 998 freescale semiconductor 28.3.2.8 flash error status register (ferstat) the ferstat register re?cts the error status of internal flash operations. all ?gs in the ferstat register are readable and only writable to clear the ?g. table 28-15. fstat field descriptions field description 7 ccif command complete interrupt flag ?the ccif ?g indicates that a flash command has completed. the ccif ?g is cleared by writing a 1 to ccif to launch a command and ccif will stay low until command completion or command violation. 0 flash command in progress 1 flash command has completed 5 accerr flash access error flag ?the accerr bit indicates an illegal access has occurred to the flash memory caused by either a violation of the command write sequence (see section 28.4.4.2 ) or issuing an illegal flash command. while accerr is set, the ccif ?g cannot be cleared to launch a command. the accerr bit is cleared by writing a 1 to accerr. writing a 0 to the accerr bit has no effect on accerr. 0 no access error detected 1 access error detected 4 fpviol flash protection violation flag ?he fpviol bit indicates an attempt was made to program or erase an address in a protected area of p-flash or eeprom memory during a command write sequence. the fpviol bit is cleared by writing a 1 to fpviol. writing a 0 to the fpviol bit has no effect on fpviol. while fpviol is set, it is not possible to launch a command or start a command write sequence. 0 no protection violation detected 1 protection violation detected 3 mgbusy memory controller busy flag ?the mgbusy ?g re?cts the active state of the memory controller . 0 memory controller is idle 1 memory controller is busy executing a flash command (ccif = 0) 2 rsvd reserved bit ?this bit is reserved and always reads 0 . 1? mgstat[1:0] memory controller command completion status flag one or more mgstat ?g bits are set if an error is detected during execution of a flash command or during the flash reset sequence. see section 28.4.6, ?lash command description , and section 28.6, ?nitialization ?for details. offset module base + 0x0007 76543210 r000000 dfdif sfdif w reset 00000000 = unimplemented or reserved figure 28-12. flash error status register (ferstat)
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 999 28.3.2.9 p-flash protection register (fprot) the fprot register de?es which p-flash sectors are protected against program and erase operations. the (unreserved) bits of the fprot register are writable with the restriction that the size of the protected region can only be increased (see section 28.3.2.9.1, ?-flash protection restrictions , and table 28-21 ). during the reset sequence, the fprot register is loaded with the contents of the p-flash protection byte in the flash con?uration ?ld at global address 0x3_ff0c located in p-flash memory (see table 28-4 ) as indicated by reset condition ??in figure 28-13 . to change the p-flash protection that will be loaded during the reset sequence, the upper sector of the p-flash memory must be unprotected, then the p-flash protection byte must be reprogrammed. if a double bit fault is detected while reading the p-flash phrase containing the p-flash protection byte during the reset sequence, the fpopen bit will be cleared and remaining bits in the fprot register will be set to leave the p-flash memory fully protected. table 28-16. ferstat field descriptions field description 1 dfdif double bit fault detect interrupt flag ?the setting of the dfdif ?g indicates that a double bit fault was detected in the stored parity and data bits during a flash array read operation or that a flash array read operation returning invalid data was attempted on a flash block that was under a flash command operation. 1 the dfdif ?g is cleared by writing a 1 to dfdif. writing a 0 to dfdif has no effect on dfdif. 2 0 no double bit fault detected 1 double bit fault detected or a flash array read operation returning invalid data was attempted while command running 1 the single bit fault and double bit fault ?gs are mutually exclusive for parity errors (an ecc fault occurrence can be either single fault or double fault but never both). a simultaneous access collision (flash array read operation returning invalid data attempted while command running) is indicated when both sfdif and dfdif ?gs are high. 2 there is a one cycle delay in storing the ecc dfdif and sfdif fault ?gs in this register. at least one nop is required after a ?sh memory read before checking ferstat for the occurrence of ecc errors. 0 sfdif single bit fault detect interrupt flag ?with the ignsf bit in the fcnfg register clear, the sfdif ?g indicates that a single bit fault was detected in the stored parity and data bits during a flash array read operation or that a flash array read operation returning invalid data was attempted on a flash block that was under a flash command operation. 1 the sfdif ?g is cleared by writing a 1 to sfdif. writing a 0 to sfdif has no effect on sfdif. 0 no single bit fault detected 1 single bit fault detected and corrected or a flash array read operation returning invalid data was attempted while command running offset module base + 0x0008 76543210 r fpopen rnv6 fphdis fphs[1:0] fpldis fpls[1:0] w reset f 1 1 loaded from ifr flash con?uration ?ld, during reset sequence. f 1 f 1 f 1 f 1 f 1 f 1 f 1 = unimplemented or reserved figure 28-13. flash protection register (fprot)
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 1000 freescale semiconductor trying to alter data in any protected area in the p-flash memory will result in a protection violation error and the fpviol bit will be set in the fstat register. the block erase of a p-flash block is not possible if any of the p-flash sectors contained in the same p-flash block are protected. table 28-17. fprot field descriptions field description 7 fpopen flash protection operation enable ?the fpopen bit determines the protection function for program or erase operations as shown in table 28-18 for the p-flash block. 0 when fpopen is clear, the fphdis and fpldis bits de?e unprotected address ranges as speci?d by the corresponding fphs and fpls bits 1 when fpopen is set, the fphdis and fpldis bits enable protection for the address range speci?d by the corresponding fphs and fpls bits 6 rnv[6] reserved nonvolatile bit ?the rnv bit should remain in the erased state for future enhancements. 5 fphdis flash protection higher address range disable ?the fphdis bit determines whether there is a protected/unprotected area in a speci? region of the p-flash memory ending with global address 0x3_ffff. 0 protection/unprotection enabled 1 protection/unprotection disabled 4? fphs[1:0] flash protection higher address size the fphs bits determine the size of the protected/unprotected area in p-flash memory as shown in table 28-19 . the fphs bits can only be written to while the fphdis bit is set. 2 fpldis flash protection lower address range disable ?the fpldis bit determines whether there is a protected/unprotected area in a speci? region of the p-flash memory beginning with global address 0x3_8000. 0 protection/unprotection enabled 1 protection/unprotection disabled 1? fpls[1:0] flash protection lower address size the fpls bits determine the size of the protected/unprotected area in p-flash memory as shown in table 28-20 . the fpls bits can only be written to while the fpldis bit is set. table 28-18. p-flash protection function fpopen fphdis fpldis function 1 1 for range sizes, refer to table 28-19 and table 28-20 . 1 1 1 no p-flash protection 1 1 0 protected low range 1 0 1 protected high range 1 0 0 protected high and low ranges 0 1 1 full p-flash memory protected 0 1 0 unprotected low range 0 0 1 unprotected high range 0 0 0 unprotected high and low ranges
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1001 all possible p-flash protection scenarios are shown in figure 28-14 . although the protection scheme is loaded from the flash memory at global address 0x3_ff0c during the reset sequence, it can be changed by the user. the p-flash protection scheme can be used by applications requiring reprogramming in single chip mode while providing as much protection as possible if reprogramming is not required. table 28-19. p-flash protection higher address range fphs[1:0] global address range protected size 00 0x3_f800?x3_ffff 2 kbytes 01 0x3_f000?x3_ffff 4 kbytes 10 0x3_e000?x3_ffff 8 kbytes 11 0x3_c000?x3_ffff 16 kbytes table 28-20. p-flash protection lower address range fpls[1:0] global address range protected size 00 0x3_8000?x3_83ff 1 kbyte 01 0x3_8000?x3_87ff 2 kbytes 10 0x3_8000?x3_8fff 4 kbytes 11 0x3_8000?x3_9fff 8 kbytes
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 1002 freescale semiconductor figure 28-14. p-flash protection scenarios 7 6 5 4 fphs[1:0] fpls[1:0] 3 2 1 0 fphs[1:0] fpls[1:0] fphdis = 1 fpldis = 1 fphdis = 1 fpldis = 0 fphdis = 0 fpldis = 1 fphdis = 0 fpldis = 0 scenario scenario unprotected region protected region with size protected region protected region with size defined by fpls defined by fphs not defined by fpls, fphs 0x3_8000 0x3_ffff 0x3_8000 0x3_ffff flash start flash start fpopen = 1 fpopen = 0
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1003 28.3.2.9.1 p-flash protection restrictions the general guideline is that p-flash protection can only be added and not removed. table 28-21 speci?s all valid transitions between p-flash protection scenarios. any attempt to write an invalid scenario to the fprot register will be ignored. the contents of the fprot register re?ct the active protection scenario. see the fphs and fpls bit descriptions for additional restrictions. 28.3.2.10 eeprom protection register (eeprot) the eeprot register de?es which eeprom sectors are protected against program and erase operations. the (unreserved) bits of the eeprot register are writable with the restriction that protection can be added but not removed. writes must increase the dps value and the dpopen bit can only be written from 1 (protection disabled) to 0 (protection enabled). if the dpopen bit is set, the state of the dps bits is irrelevant. during the reset sequence, ?lds dpopen and dps of the eeprot register are loaded with the contents of the eeprom protection byte in the flash configuration field at global address 0x3_ff0d located in table 28-21. p-flash protection scenario transitions from protection scenario to protection scenario 1 1 allowed transitions marked with x, see figure 28-14 for a de?ition of the scenarios. 01234567 0 xxxx 1 xx 2 xx 3 x 4 xx 5 xxxx 6 xxxx 7 xxxxxxxx offset module base + 0x0009 76543210 r dpopen dps[6:0] w reset f 1 1 loaded from ifr flash con?uration ?ld, during reset sequence. f 1 f 1 f 1 f 1 f 1 f 1 f 1 figure 28-15. eeprom protection register (eeprot)
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 1004 freescale semiconductor p-flash memory (see table 28-4 ) as indicated by reset condition f in table 28-23 . to change the eeprom protection that will be loaded during the reset sequence, the p-flash sector containing the eeprom protection byte must be unprotected, then the eeprom protection byte must be programmed. if a double bit fault is detected while reading the p-flash phrase containing the eeprom protection byte during the reset sequence, the dpopen bit will be cleared and dps bits will be set to leave the eeprom memory fully protected. trying to alter data in any protected area in the eeprom memory will result in a protection violation error and the fpviol bit will be set in the fstat register. block erase of the eeprom memory is not possible if any of the eeprom sectors are protected. table 28-22. eeprot field descriptions field description 7 dpopen eeprom protection control 0 enables eeprom memory protection from program and erase with protected address range de?ed by dps bits 1 disables eeprom memory protection from program and erase 6? dps[6:0] eeprom protection size ?the dps[6:0] bits determine the size of the protected area in the eeprom memory, this size increase in step of 32 bytes, as shown in table 28-23 . table 28-23. eeprom protection address range dps[6:0] global address range protected size 0000000 0x0_0400 ?0x0_041f 32 bytes 0000001 0x0_0400 ?0x0_043f 64 bytes 0000010 0x0_0400 ?0x0_045f 96 bytes 0000011 0x0_0400 ?0x0_047f 128 bytes 0000100 0x0_0400 ?0x0_049f 160 bytes 0000101 0x0_0400 ?0x0_04bf 192 bytes the protection size goes on enlarging in step of 32 bytes, for each dps value increasing of one. . . . 1011111 - to - 1111111 0x0_0400 ?0x0_0fff 3,072 bytes
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1005 28.3.2.11 flash common command object register (fccob) the fccob is an array of six words addressed via the ccobix index found in the fccobix register. byte wide reads and writes are allowed to the fccob register. 28.3.2.11.1 fccob - nvm command mode nvm command mode uses the indexed fccob register to provide a command code and its relevant parameters to the memory controller. the user ?st sets up all required fccob ?lds and then initiates the commands execution by writing a 1 to the ccif bit in the fstat register (a 1 written by the user clears the ccif command completion ?g to 0). when the user clears the ccif bit in the fstat register all fccob parameter ?lds are locked and cannot be changed by the user until the command completes (as evidenced by the memory controller returning ccif to 1). some commands return information to the fccob register array. the generic format for the fccob parameter ?lds in nvm command mode is shown in table 28-24 . the return values are available for reading after the ccif ?g in the fstat register has been returned to 1 by the memory controller. writes to the unimplemented parameter ?lds (ccobix = 110 and ccobix = 111) are ignored with reads from these ?lds returning 0x0000. table 28-24 shows the generic flash command format. the high byte of the ?st word in the ccob array contains the command code, followed by the parameters for this speci? flash command. for details on the fccob settings required by each command, see the flash command descriptions in section 28.4.6 . offset module base + 0x000a 76543210 r ccob[15:8] w reset 00000000 figure 28-16. flash common command object high register (fccobhi) offset module base + 0x000b 76543210 r ccob[7:0] w reset 00000000 figure 28-17. flash common command object low register (fccoblo) table 28-24. fccob - nvm command mode (typical usage) ccobix[2:0] byte fccob parameter fields (nvm command mode) 000 hi fcmd[7:0] de?ing flash command lo 6?0, global address [17:16] 001 hi global address [15:8] lo global address [7:0]
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 1006 freescale semiconductor 28.3.2.12 flash reserved1 register (frsv1) this flash register is reserved for factory testing. all bits in the frsv1 register read 0 and are not writable. 28.3.2.13 flash reserved2 register (frsv2) this flash register is reserved for factory testing. all bits in the frsv2 register read 0 and are not writable. 28.3.2.14 flash reserved3 register (frsv3) this flash register is reserved for factory testing. 010 hi data 0 [15:8] lo data 0 [7:0] 011 hi data 1 [15:8] lo data 1 [7:0] 100 hi data 2 [15:8] lo data 2 [7:0] 101 hi data 3 [15:8] lo data 3 [7:0] offset module base + 0x000c 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 28-18. flash reserved1 register (frsv1) offset module base + 0x000d 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 28-19. flash reserved2 register (frsv2) table 28-24. fccob - nvm command mode (typical usage) ccobix[2:0] byte fccob parameter fields (nvm command mode)
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1007 all bits in the frsv3 register read 0 and are not writable. 28.3.2.15 flash reserved4 register (frsv4) this flash register is reserved for factory testing. all bits in the frsv4 register read 0 and are not writable. 28.3.2.16 flash option register (fopt) the fopt register is the flash option register. all bits in the fopt register are readable but are not writable. during the reset sequence, the fopt register is loaded from the flash nonvolatile byte in the flash con?uration ?ld at global address 0x3_ff0e located in p-flash memory (see table 28-4 ) as indicated by reset condition f in figure 28-22 . if a double bit fault is detected while reading the p-flash phrase containing the flash nonvolatile byte during the reset sequence, all bits in the fopt register will be set. offset module base + 0x000e 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 28-20. flash reserved3 register (frsv3) offset module base + 0x000f 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 28-21. flash reserved4 register (frsv4) offset module base + 0x0010 76543210 r nv[7:0] w reset f 1 1 loaded from ifr flash con?uration ?ld, during reset sequence. f 1 f 1 f 1 f 1 f 1 f 1 f 1 = unimplemented or reserved figure 28-22. flash option register (fopt)
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 1008 freescale semiconductor 28.3.2.17 flash reserved5 register (frsv5) this flash register is reserved for factory testing. all bits in the frsv5 register read 0 and are not writable. 28.3.2.18 flash reserved6 register (frsv6) this flash register is reserved for factory testing. all bits in the frsv6 register read 0 and are not writable. 28.3.2.19 flash reserved7 register (frsv7) this flash register is reserved for factory testing. table 28-25. fopt field descriptions field description 7? nv[7:0] nonvolatile bits the nv[7:0] bits are available as nonvolatile bits. refer to the device user guide for proper use of the nv bits. offset module base + 0x0011 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 28-23. flash reserved5 register (frsv5) offset module base + 0x0012 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 28-24. flash reserved6 register (frsv6)
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1009 all bits in the frsv7 register read 0 and are not writable. 28.4 functional description 28.4.1 modes of operation the ftmrg96k1 module provides the modes of operation normal and special . the operating mode is determined by module-level inputs and affects the fclkdiv, fcnfg, and eeprot registers (see table 28-27 ). 28.4.2 ifr version id word the version id word is stored in the ifr at address 0x0_40b6. the contents of the word are de?ed in table 28-26 . vernum: version number. the ?st version is number 0b_0001 with both 0b_0000 and 0b_1111 meaning ?one? offset module base + 0x0013 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 28-25. flash reserved7 register (frsv7) table 28-26. ifr version id fields [15:4] [3:0] reserved vernum
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 1010 freescale semiconductor 28.4.3 internal nvm resource (nvmres) ifr is an internal nvm resource readable by cpu , when nvmres is active. the ifr ?lds are shown in table 28-5 . the nvmres global address map is shown in table 28-6 . 28.4.4 flash command operations flash command operations are used to modify flash memory contents. the next sections describe: how to write the fclkdiv register that is used to generate a time base (fclk) derived from busclk for flash program and erase command operations the command write sequence used to set flash command parameters and launch execution valid flash commands available for execution, according to mcu functional mode and mcu security state. 28.4.4.1 writing the fclkdiv register prior to issuing any flash program or erase command after a reset, the user is required to write the fclkdiv register to divide busclk down to a target fclk of 1 mhz. table 28-8 shows recommended values for the fdiv ?ld based on busclk frequency. note programming or erasing the flash memory cannot be performed if the bus clock runs at less than 0.8 mhz. setting fdiv too high can destroy the flash memory due to overstress. setting fdiv too low can result in incomplete programming or erasure of the flash memory cells. when the fclkdiv register is written, the fdivld bit is set automatically. if the fdivld bit is 0, the fclkdiv register has not been written since the last reset. if the fclkdiv register has not been written, any flash program or erase command loaded during a command write sequence will not execute and the accerr bit in the fstat register will set. 28.4.4.2 command write sequence the memory controller will launch all valid flash commands entered using a command write sequence. before launching a command, the accerr and fpviol bits in the fstat register must be clear (see section 28.3.2.7 ) and the ccif ?g should be tested to determine the status of the current command write sequence. if ccif is 0, the previous command write sequence is still active, a new command write sequence cannot be started, and all writes to the fccob register are ignored.
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1011 28.4.4.2.1 de?e fccob contents the fccob parameter ?lds must be loaded with all required parameters for the flash command being executed. access to the fccob parameter ?lds is controlled via the ccobix bits in the fccobix register (see section 28.3.2.3 ). the contents of the fccob parameter ?lds are transferred to the memory controller when the user clears the ccif command completion ?g in the fstat register (writing 1 clears the ccif to 0). the ccif ?g will remain clear until the flash command has completed. upon completion, the memory controller will return ccif to 1 and the fccob register will be used to communicate any results. the ?w for a generic command write sequence is shown in figure 28-26 .
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 1012 freescale semiconductor figure 28-26. generic flash command write sequence flowchart write to fccobix register write: fstat register (to launch command) clear ccif 0x80 clear accerr/fpviol 0x30 write: fstat register yes no access error and protection violation read: fstat register start check fccob accerr/ fpviol set? exit write: fclkdiv register read: fclkdiv register yes no fdiv correct? no bit polling for command completion check yes ccif set? to identify speci? command parameter to load. write to fccob register to load required command parameter. yes no more parameters? availability check results from previous command note: fclkdiv must be set after each reset read: fstat register no yes ccif set? no yes ccif set? clock divider value check read: fstat register
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1013 28.4.4.3 valid flash module commands table 28-27 present the valid flash commands, as enabled by the combination of the functional mcu mode (normal singlechip ns, special singlechip ss) with the mcu security state (unsecured, secured). special singlechip mode is selected by input mmc_ss_mode_ts2 asserted. mcu secured state is selected by input mmc_secure input asserted. + 28.4.4.4 p-flash commands table 28-28 summarizes the valid p-flash commands along with the effects of the commands on the p-flash block and other resources within the flash module. table 28-27. flash commands by mode and security state fcmd command unsecured secured ns 1 1 unsecured normal single chip mode ss 2 2 unsecured special single chip mode. ns 3 3 secured normal single chip mode. ss 4 4 secured special single chip mode. 0x01 erase verify all blocks ???? 0x02 erase verify block ???? 0x03 erase verify p-flash section ??? 0x04 read once ??? 0x06 program p-flash ??? 0x07 program once ??? 0x08 erase all blocks ?? 0x09 erase flash block ??? 0x0a erase p-flash sector ??? 0x0b unsecure flash ?? 0x0c verify backdoor access key ?? 0x0d set user margin level ??? 0x0e set field margin level ? 0x10 erase verify eeprom section ??? 0x11 program eeprom ??? 0x12 erase eeprom sector ??? table 28-28. p-flash commands fcmd command function on p-flash memory 0x01 erase verify all blocks verify that all p-flash (and eeprom) blocks are erased.
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 1014 freescale semiconductor 28.4.4.5 eeprom commands table 28-29 summarizes the valid eeprom commands along with the effects of the commands on the eeprom block. 0x02 erase verify block verify that a p-flash block is erased. 0x03 erase verify p-flash section verify that a given number of words starting at the address provided are erased. 0x04 read once read a dedicated 64 byte ?ld in the nonvolatile information register in p-flash block that was previously programmed using the program once command. 0x06 program p-flash program a phrase in a p-flash block. 0x07 program once program a dedicated 64 byte ?ld in the nonvolatile information register in p-flash block that is allowed to be programmed only once. 0x08 erase all blocks erase all p-flash (and eeprom) blocks. an erase of all flash blocks is only possible when the fpldis, fphdis, and fpopen bits in the fprot register and the dpopen bit in the eeprot register are set prior to launching the command. 0x09 erase flash block erase a p-flash (or eeprom) block. an erase of the full p-flash block is only possible when fpldis, fphdis and fpopen bits in the fprot register are set prior to launching the command. 0x0a erase p-flash sector erase all bytes in a p-flash sector. 0x0b unsecure flash supports a method of releasing mcu security by erasing all p-flash (and eeprom) blocks and verifying that all p-flash (and eeprom) blocks are erased. 0x0c verify backdoor access key supports a method of releasing mcu security by verifying a set of security keys. 0x0d set user margin level speci?s a user margin read level for all p-flash blocks. 0x0e set field margin level speci?s a ?ld margin read level for all p-flash blocks (special modes only). table 28-29. eeprom commands fcmd command function on eeprom memory 0x01 erase verify all blocks verify that all eeprom (and p-flash) blocks are erased. 0x02 erase verify block verify that the eeprom block is erased. table 28-28. p-flash commands fcmd command function on p-flash memory
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1015 28.4.5 allowed simultaneous p-flash and eeprom operations only the operations marked ?k?in table 28-30 are permitted to be run simultaneously on the program flash and eeprom blocks. some operations cannot be executed simultaneously because certain hardware resources are shared by the two memories. the priority has been placed on permitting program flash reads while program and erase operations execute on the eeprom, providing read (p-flash) while write (eeprom) functionality. 0x08 erase all blocks erase all eeprom (and p-flash) blocks. an erase of all flash blocks is only possible when the fpldis, fphdis, and fpopen bits in the fprot register and the dpopen bit in the eeprot register are set prior to launching the command. 0x09 erase flash block erase a eeprom (or p-flash) block. an erase of the full eeprom block is only possible when dpopen bit in the eeprot register is set prior to launching the command. 0x0b unsecure flash supports a method of releasing mcu security by erasing all eeprom (and p-flash) blocks and verifying that all eeprom (and p-flash) blocks are erased. 0x0d set user margin level speci?s a user margin read level for the eeprom block. 0x0e set field margin level speci?s a ?ld margin read level for the eeprom block (special modes only). 0x10 erase verify eeprom section verify that a given number of words starting at the address provided are erased. 0x11 program eeprom program up to four words in the eeprom block. 0x12 erase eeprom sector erase all bytes in a sector of the eeprom block. table 28-30. allowed p-flash and eeprom simultaneous operations eeprom program flash read margin read 1 program sector erase mass erase 2 read ok ok ok margin read 1 1 a ?argin read?is any read after executing the margin setting commands ?et user margin level?or ?et field margin level?with anything but the ?ormal level speci?d. see the note on margin settings in section 28.4.6.12 and section 28.4.6.13 . program sector erase mass erase 2 2 the ?ass erase?operations are commands ?rase all blocks?and ?rase flash block ok table 28-29. eeprom commands fcmd command function on eeprom memory
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 1016 freescale semiconductor 28.4.6 flash command description this section provides details of all available flash commands launched by a command write sequence. the accerr bit in the fstat register will be set during the command write sequence if any of the following illegal steps are performed, causing the command not to be processed by the memory controller: starting any command write sequence that programs or erases flash memory before initializing the fclkdiv register writing an invalid command as part of the command write sequence for additional possible errors, refer to the error handling table provided for each command if a flash block is read during execution of an algorithm (ccif = 0) on that same block, the read operation will return invalid data if both ?gs sfdif and dfdif are set. if the sfdif or dfdif ?gs were not previously set when the invalid read operation occurred, both the sfdif and dfdif ?gs will be set. if the accerr or fpviol bits are set in the fstat register, the user must clear these bits before starting any command write sequence (see section 28.3.2.7 ). caution a flash word or phrase must be in the erased state before being programmed. cumulative programming of bits within a flash word or phrase is not allowed. 28.4.6.1 erase verify all blocks command the erase verify all blocks command will verify that all p-flash and eeprom blocks have been erased. upon clearing ccif to launch the erase verify all blocks command, the memory controller will verify that the entire flash memory space is erased. the ccif ?g will set after the erase verify all blocks operation has completed. if all blocks are not erased, it means blank check failed, both mgstat bits will be set. table 28-31. erase verify all blocks command fccob requirements ccobix[2:0] fccob parameters 000 0x01 not required table 28-32. erase verify all blocks command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 000 at command launch fpviol none mgstat1 set if any errors have been encountered during the read 1 or if blank check failed . 1 as found in the memory map for ftmrg96k1. mgstat0 set if any non-correctable errors have been encountered during the read 1 or if blank check failed.
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1017 28.4.6.2 erase verify block command the erase verify block command allows the user to verify that an entire p-flash or eeprom block has been erased. the fccob flashblockselectioncode[1:0] bits determine which block must be veri?d. upon clearing ccif to launch the erase verify block command, the memory controller will verify that the selected p-flash or eeprom block is erased. the ccif ?g will set after the erase verify block operation has completed.if the block is not erased, it means blank check failed, both mgstat bits will be set. table 28-33. erase verify block command fccob requirements ccobix[2:0] fccob parameters 000 0x02 flash block selection code [1:0] . see table 28-34 table 28-34. flash block selection code description selection code[1:0] flash block to be veri?d 00 eeprom 01 invalid (accerr) 10 p-flash 11 p-flash table 28-35. erase verify block command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 000 at command launch set if an invalid flashblockselectioncode[1:0] is supplied 1 1 as de?ed by the memory map for ftmrg96k1. fpviol none mgstat1 set if any errors have been encountered during the read 2 or if blank check failed. 2 as found in the memory map for ftmrg96k1. mgstat0 set if any non-correctable errors have been encountered during the read 2 or if blank check failed.
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 1018 freescale semiconductor 28.4.6.3 erase verify p-flash section command the erase verify p-flash section command will verify that a section of code in the p-flash memory is erased. the erase verify p-flash section command de?es the starting point of the code to be veri?d and the number of phrases. upon clearing ccif to launch the erase verify p-flash section command, the memory controller will verify the selected section of flash memory is erased. the ccif ?g will set after the erase verify p-flash section operation has completed. if the section is not erased, it means blank check failed, both mgstat bits will be set. 28.4.6.4 read once command the read once command provides read access to a reserved 64 byte ?ld (8 phrases) located in the nonvolatile information register of p-flash. the read once ?ld is programmed using the program once command described in section 28.4.6.6 . the read once command must not be executed from the flash block containing the program once reserved ?ld to avoid code runaway. table 28-36. erase verify p-flash section command fccob requirements ccobix[2:0] fccob parameters 000 0x03 global address [17:16] of a p-flash block 001 global address [15:0] of the ?st phrase to be veri?d 010 number of phrases to be veri?d table 28-37. erase verify p-flash section command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 010 at command launch set if command not available in current mode (see table 28-27 ) set if an invalid global address [17:0] is supplied see table 28-3 ) 1 1 as de?ed by the memory map for ftmrg96k1. set if a misaligned phrase address is supplied (global address [2:0] != 000) set if the requested section crosses a the p-flash address boundary fpviol none mgstat1 set if any errors have been encountered during the read 2 or if blank check failed. 2 as found in the memory map for ftmrg96k1. mgstat0 set if any non-correctable errors have been encountered during the read 2 or if blank check failed. table 28-38. read once command fccob requirements ccobix[2:0] fccob parameters 000 0x04 not required
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1019 upon clearing ccif to launch the read once command, a read once phrase is fetched and stored in the fccob indexed register. the ccif ?g will set after the read once operation has completed. valid phrase index values for the read once command range from 0x0000 to 0x0007. during execution of the read once command, any attempt to read addresses within p-flash block will return invalid data. 8 28.4.6.5 program p-flash command the program p-flash operation will program a previously erased phrase in the p-flash memory using an embedded algorithm. caution a p-flash phrase must be in the erased state before being programmed. cumulative programming of bits within a flash phrase is not allowed. 001 read once phrase index (0x0000 - 0x0007) 010 read once word 0 value 011 read once word 1 value 100 read once word 2 value 101 read once word 3 value table 28-39. read once command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 28-27 ) set if an invalid phrase index is supplied fpviol none mgstat1 set if any errors have been encountered during the read mgstat0 set if any non-correctable errors have been encountered during the read table 28-40. program p-flash command fccob requirements ccobix[2:0] fccob parameters 000 0x06 global address [17:16] to identify p-flash block 001 global address [15:0] of phrase location to be programmed 1 010 word 0 program value 011 word 1 program value 100 word 2 program value 101 word 3 program value table 28-38. read once command fccob requirements ccobix[2:0] fccob parameters
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 1020 freescale semiconductor upon clearing ccif to launch the program p-flash command, the memory controller will program the data words to the supplied global address and will then proceed to verify the data words read back as expected. the ccif ?g will set after the program p-flash operation has completed. 28.4.6.6 program once command the program once command restricts programming to a reserved 64 byte ?ld (8 phrases) in the nonvolatile information register located in p-flash. the program once reserved ?ld can be read using the read once command as described in section 28.4.6.4 . the program once command must only be issued once since the nonvolatile information register in p-flash cannot be erased. the program once command must not be executed from the flash block containing the program once reserved ?ld to avoid code runaway. upon clearing ccif to launch the program once command, the memory controller ?st veri?s that the selected phrase is erased. if erased, then the selected phrase will be programmed and then veri?d with read back. the ccif ?g will remain clear, setting only after the program once operation has completed. 1 global address [2:0] must be 000 table 28-41. program p-flash command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 101 at command launch set if command not available in current mode (see table 28-27 ) set if an invalid global address [17:0] is supplied see table 28-3 ) 1 1 as de?ed by the memory map for ftmrg96k1. set if a misaligned phrase address is supplied (global address [2:0] != 000) fpviol set if the global address [17:0] points to a protected area mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation table 28-42. program once command fccob requirements ccobix[2:0] fccob parameters 000 0x07 not required 001 program once phrase index (0x0000 - 0x0007) 010 program once word 0 value 011 program once word 1 value 100 program once word 2 value 101 program once word 3 value
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1021 the reserved nonvolatile information register accessed by the program once command cannot be erased and any attempt to program one of these phrases a second time will not be allowed. valid phrase index values for the program once command range from 0x0000 to 0x0007. during execution of the program once command, any attempt to read addresses within p-flash will return invalid data. 28.4.6.7 erase all blocks command the erase all blocks operation will erase the entire p-flash and eeprom memory space. upon clearing ccif to launch the erase all blocks command, the memory controller will erase the entire flash memory space and verify that it is erased. if the memory controller veri?s that the entire flash memory space was properly erased, security will be released. during the execution of this command (ccif=0) the user must not write to any flash module register. the ccif ?g will set after the erase all blocks operation has completed. table 28-43. program once command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 101 at command launch set if command not available in current mode (see table 28-27 ) set if an invalid phrase index is supplied set if the requested phrase has already been programmed 1 1 if a program once phrase is initially programmed to 0xffff_ffff_ffff_ffff, the program once command will be allowed to execute again on that same phrase. fpviol none mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation table 28-44. erase all blocks command fccob requirements ccobix[2:0] fccob parameters 000 0x08 not required table 28-45. erase all blocks command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 000 at command launch set if command not available in current mode (see table 28-27 ) fpviol set if any area of the p-flash or eeprom memory is protected mgstat1 set if any errors have been encountered during the verify operation 1 1 as found in the memory map for ftmrg96k1. mgstat0 set if any non-correctable errors have been encountered during the verify operation 1
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 1022 freescale semiconductor 28.4.6.8 erase flash block command the erase flash block operation will erase all addresses in a p-flash or eeprom block. upon clearing ccif to launch the erase flash block command, the memory controller will erase the selected flash block and verify that it is erased. the ccif ?g will set after the erase flash block operation has completed. 28.4.6.9 erase p-flash sector command the erase p-flash sector operation will erase all addresses in a p-flash sector. upon clearing ccif to launch the erase p-flash sector command, the memory controller will erase the selected flash sector and then verify that it is erased. the ccif ?g will be set after the erase p-flash sector operation has completed. table 28-46. erase flash block command fccob requirements ccobix[2:0] fccob parameters 000 0x09 global address [17:16] to identify flash block 001 global address [15:0] in flash block to be erased table 28-47. erase flash block command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 28-27 ) set if an invalid global address [17:16] is supplied 1 1 as de?ed by the memory map for ftmrg96k1. set if the supplied p-flash address is not phrase-aligned or if the eeprom address is not word-aligned fpviol set if an area of the selected flash block is protected mgstat1 set if any errors have been encountered during the verify operation 2 2 as found in the memory map for ftmrg96k1. mgstat0 set if any non-correctable errors have been encountered during the verify operation 2 table 28-48. erase p-flash sector command fccob requirements ccobix[2:0] fccob parameters 000 0x0a global address [17:16] to identify p-flash block to be erased 001 global address [15:0] anywhere within the sector to be erased. refer to section 28.1.2.1 for the p-flash sector size.
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1023 28.4.6.10 unsecure flash command the unsecure flash command will erase the entire p-flash and eeprom memory space and, if the erase is successful, will release security. upon clearing ccif to launch the unsecure flash command, the memory controller will erase the entire p-flash and eeprom memory space and verify that it is erased. if the memory controller veri?s that the entire flash memory space was properly erased, security will be released. if the erase verify is not successful, the unsecure flash operation sets mgstat1 and terminates without changing the security state. during the execution of this command (ccif=0) the user must not write to any flash module register. the ccif ?g is set after the unsecure flash operation has completed. table 28-49. erase p-flash sector command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 28-27 ) set if an invalid global address [17:16] is supplied see table 28-3 ) 1 1 as de?ed by the memory map for ftmrg96k1. set if a misaligned phrase address is supplied (global address [2:0] != 000) fpviol set if the selected p-flash sector is protected mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation table 28-50. unsecure flash command fccob requirements ccobix[2:0] fccob parameters 000 0x0b not required table 28-51. unsecure flash command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 000 at command launch set if command not available in current mode (see table 28-27 ) fpviol set if any area of the p-flash or eeprom memory is protected mgstat1 set if any errors have been encountered during the verify operation 1 1 as found in the memory map for ftmrg96k1. mgstat0 set if any non-correctable errors have been encountered during the verify operation 1
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 1024 freescale semiconductor 28.4.6.11 verify backdoor access key command the verify backdoor access key command will only execute if it is enabled by the keyen bits in the fsec register (see table 28-10 ). the verify backdoor access key command releases security if user-supplied keys match those stored in the flash security bytes of the flash con?uration ?ld (see table 28-4 ). the verify backdoor access key command must not be executed from the flash block containing the backdoor comparison key to avoid code runaway. upon clearing ccif to launch the verify backdoor access key command, the memory controller will check the fsec keyen bits to verify that this command is enabled. if not enabled, the memory controller sets the accerr bit in the fstat register and terminates. if the command is enabled, the memory controller compares the key provided in fccob to the backdoor comparison key in the flash con?uration ?ld with key 0 compared to 0x3_ff00, etc. if the backdoor keys match, security will be released. if the backdoor keys do not match, security is not released and all future attempts to execute the verify backdoor access key command are aborted (set accerr) until a reset occurs. the ccif flag is set after the verify backdoor access key operation has completed. 28.4.6.12 set user margin level command the set user margin level command causes the memory controller to set the margin level for future read operations of the p-flash or eeprom block. table 28-52. verify backdoor access key command fccob requirements ccobix[2:0] fccob parameters 000 0x0c not required 001 key 0 010 key 1 011 key 2 100 key 3 table 28-53. verify backdoor access key command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 100 at command launch set if an incorrect backdoor key is supplied set if backdoor key access has not been enabled (keyen[1:0] != 10, see section 28.3.2.2 ) set if the backdoor key has mismatched since the last reset fpviol none mgstat1 none mgstat0 none
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1025 upon clearing ccif to launch the set user margin level command, the memory controller will set the user margin level for the targeted block and then set the ccif ?g. note when the eeprom block is targeted, the eeprom user margin levels are applied only to the eeprom reads. however, when the p-flash block is targeted, the p-flash user margin levels are applied to both p-flash and eeprom reads. it is not possible to apply user margin levels to the p-flash block only. valid margin level settings for the set user margin level command are de?ed in table 28-55 . table 28-54. set user margin level command fccob requirements ccobix[2:0] fccob parameters 000 0x0d flash block selection code [1:0] . see table 28-34 001 margin level setting. table 28-55. valid set user margin level settings ccob (ccobix=001) level description 0x0000 return to normal level 0x0001 user margin-1 level 1 1 read margin to the erased state 0x0002 user margin-0 level 2 2 read margin to the programmed state table 28-56. set user margin level command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 28-27 ) set if an invalid flashblockselectioncode[1:0] is supplied (see table 28-34 ) set if an invalid margin level setting is supplied fpviol none mgstat1 none mgstat0 none
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 1026 freescale semiconductor note user margin levels can be used to check that flash memory contents have adequate margin for normal level read operations. if unexpected results are encountered when checking flash memory contents at user margin levels, a potential loss of information has been detected. 28.4.6.13 set field margin level command the set field margin level command, valid in special modes only, causes the memory controller to set the margin level speci?d for future read operations of the p-flash or eeprom block. upon clearing ccif to launch the set field margin level command, the memory controller will set the ?ld margin level for the targeted block and then set the ccif ?g. note when the eeprom block is targeted, the eeprom ?ld margin levels are applied only to the eeprom reads. however, when the p-flash block is targeted, the p-flash ?ld margin levels are applied to both p-flash and eeprom reads. it is not possible to apply ?ld margin levels to the p-flash block only. valid margin level settings for the set field margin level command are de?ed in table 28-58 . table 28-57. set field margin level command fccob requirements ccobix[2:0] fccob parameters 000 0x0e flash block selection code [1:0] . see table 28-34 001 margin level setting. table 28-58. valid set field margin level settings ccob (ccobix=001) level description 0x0000 return to normal level 0x0001 user margin-1 level 1 1 read margin to the erased state 0x0002 user margin-0 level 2 2 read margin to the programmed state 0x0003 field margin-1 level 1 0x0004 field margin-0 level 2
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1027 caution field margin levels must only be used during verify of the initial factory programming. note field margin levels can be used to check that flash memory contents have adequate margin for data retention at the normal level setting. if unexpected results are encountered when checking flash memory contents at ?ld margin levels, the flash memory contents should be erased and reprogrammed. 28.4.6.14 erase verify eeprom section command the erase verify eeprom section command will verify that a section of code in the eeprom is erased. the erase verify eeprom section command de?es the starting point of the data to be veri?d and the number of words. upon clearing ccif to launch the erase verify eeprom section command, the memory controller will verify the selected section of eeprom memory is erased. the ccif ?g will set after the erase verify eeprom section operation has completed. if the section is not erased, it means blank check failed, both mgstat bits will be set. table 28-59. set field margin level command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 28-27 ) set if an invalid flashblockselectioncode[1:0] is supplied (see table 28-34 ) 1 1 as de?ed by the memory map for ftmrg96k1. set if an invalid margin level setting is supplied fpviol none mgstat1 none mgstat0 none table 28-60. erase verify eeprom section command fccob requirements ccobix[2:0] fccob parameters 000 0x10 global address [17:16] to identify the eeprom block 001 global address [15:0] of the ?st word to be veri?d 010 number of words to be veri?d
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 1028 freescale semiconductor 28.4.6.15 program eeprom command the program eeprom operation programs one to four previously erased words in the eeprom block. the program eeprom operation will con?m that the targeted location(s) were successfully programmed upon completion. caution a flash word must be in the erased state before being programmed. cumulative programming of bits within a flash word is not allowed. upon clearing ccif to launch the program eeprom command, the user-supplied words will be transferred to the memory controller and be programmed if the area is unprotected. the ccobix index value at program eeprom command launch determines how many words will be programmed in the eeprom block. the ccif ?g is set when the operation has completed. table 28-61. erase verify eeprom section command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 010 at command launch set if command not available in current mode (see table 28-27 ) set if an invalid global address [17:0] is supplied set if a misaligned word address is supplied (global address [0] != 0) set if the requested section breaches the end of the eeprom block fpviol none mgstat1 set if any errors have been encountered during the read or if blank check failed. mgstat0 set if any non-correctable errors have been encountered during the read or if blank check failed. table 28-62. program eeprom command fccob requirements ccobix[2:0] fccob parameters 000 0x11 global address [17:16] to identify the eeprom block 001 global address [15:0] of word to be programmed 010 word 0 program value 011 word 1 program value, if desired 100 word 2 program value, if desired 101 word 3 program value, if desired
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1029 28.4.6.16 erase eeprom sector command the erase eeprom sector operation will erase all addresses in a sector of the eeprom block. upon clearing ccif to launch the erase eeprom sector command, the memory controller will erase the selected flash sector and verify that it is erased. the ccif ?g will set after the erase eeprom sector operation has completed. table 28-63. program eeprom command error handling register error bit error condition fstat accerr set if ccobix[2:0] < 010 at command launch set if ccobix[2:0] > 101 at command launch set if command not available in current mode (see table 28-27 ) set if an invalid global address [17:0] is supplied set if a misaligned word address is supplied (global address [0] != 0) set if the requested group of words breaches the end of the eeprom block fpviol set if the selected area of the eeprom memory is protected mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation table 28-64. erase eeprom sector command fccob requirements ccobix[2:0] fccob parameters 000 0x12 global address [17:16] to identify eeprom block 001 global address [15:0] anywhere within the sector to be erased. see section 28.1.2.2 for eeprom sector size. table 28-65. erase eeprom sector command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 28-27 ) set if an invalid global address [17:0] is suppliedsee table 28-3 ) set if a misaligned word address is supplied (global address [0] != 0) fpviol set if the selected area of the eeprom memory is protected mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 1030 freescale semiconductor 28.4.7 interrupts the flash module can generate an interrupt when a flash command operation has completed or when a flash command operation has detected an ecc fault. note vector addresses and their relative interrupt priority are determined at the mcu level. 28.4.7.1 description of flash interrupt operation the flash module uses the ccif ?g in combination with the ccie interrupt enable bit to generate the flash command interrupt request. the flash module uses the dfdif and sfdif ?gs in combination with the dfdie and sfdie interrupt enable bits to generate the flash error interrupt request. for a detailed description of the register bits involved, refer to section 28.3.2.5, ?lash configuration register (fcnfg) ? section 28.3.2.6, ?lash error configuration register (fercnfg) ? section 28.3.2.7, ?lash status register (fstat) ? and section 28.3.2.8, ?lash error status register (ferstat) ? the logic used for generating the flash module interrupts is shown in figure 28-27 . figure 28-27. flash module interrupts implementation table 28-66. flash interrupt sources interrupt source interrupt flag local enable global (ccr) mask flash command complete ccif (fstat register) ccie (fcnfg register) i bit ecc double bit fault on flash read dfdif (ferstat register) dfdie (fercnfg register) i bit ecc single bit fault on flash read sfdif (ferstat register) sfdie (fercnfg register) i bit flash error interrupt request ccif ccie dfdif dfdie sfdif sfdie flash command interrupt request
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1031 28.4.8 wait mode the flash module is not affected if the mcu enters wait mode. the flash module can recover the mcu from wait via the ccif interrupt (see section 28.4.7, ?nterrupts ). 28.4.9 stop mode if a flash command is active (ccif = 0) when the mcu requests stop mode, the current flash operation will be completed before the mcu is allowed to enter stop mode. 28.5 security the flash module provides security information to the mcu. the flash security state is de?ed by the sec bits of the fsec register (see table 28-11 ). during reset, the flash module initializes the fsec register using data read from the security byte of the flash con?uration ?ld at global address 0x3_ff0f. the security state out of reset can be permanently changed by programming the security byte assuming that the mcu is starting from a mode where the necessary p-flash erase and program commands are available and that the upper region of the p-flash is unprotected. if the flash security byte is successfully programmed, its new value will take affect after the next mcu reset. the following subsections describe these security-related subjects: unsecuring the mcu using backdoor key access unsecuring the mcu in special single chip mode using bdm mode and security effects on flash command availability 28.5.1 unsecuring the mcu using backdoor key access the mcu may be unsecured by using the backdoor key access feature which requires knowledge of the contents of the backdoor keys (four 16-bit words programmed at addresses 0x3_ff00-0x3_ff07). if the keyen[1:0] bits are in the enabled state (see section 28.3.2.2 ), the verify backdoor access key command (see section 28.4.6.11 ) allows the user to present four prospective keys for comparison to the keys stored in the flash memory via the memory controller. if the keys presented in the verify backdoor access key command match the backdoor keys stored in the flash memory, the sec bits in the fsec register (see table 28-11 ) will be changed to unsecure the mcu. key values of 0x0000 and 0xffff are not permitted as backdoor keys. while the verify backdoor access key command is active, p-flash memory and eeprom memory will not be available for read access and will return invalid data.
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 1032 freescale semiconductor the user code stored in the p-flash memory must have a method of receiving the backdoor keys from an external stimulus. this external stimulus would typically be through one of the on-chip serial ports. if the keyen[1:0] bits are in the enabled state (see section 28.3.2.2 ), the mcu can be unsecured by the backdoor key access sequence described below: 1. follow the command sequence for the verify backdoor access key command as explained in section 28.4.6.11 2. if the verify backdoor access key command is successful, the mcu is unsecured and the sec[1:0] bits in the fsec register are forced to the unsecure state of 10 the verify backdoor access key command is monitored by the memory controller and an illegal key will prohibit future use of the verify backdoor access key command. a reset of the mcu is the only method to re-enable the verify backdoor access key command. the security as de?ed in the flash security byte (0x3_ff0f) is not changed by using the verify backdoor access key command sequence. the backdoor keys stored in addresses 0x3_ff00-0x3_ff07 are unaffected by the verify backdoor access key command sequence. the verify backdoor access key command sequence has no effect on the program and erase protections de?ed in the flash protection register, fprot. after the backdoor keys have been correctly matched, the mcu will be unsecured. after the mcu is unsecured, the sector containing the flash security byte can be erased and the flash security byte can be reprogrammed to the unsecure state, if desired. in the unsecure state, the user has full control of the contents of the backdoor keys by programming addresses 0x3_ff00-0x3_ff07 in the flash con?uration ?ld. 28.5.2 unsecuring the mcu in special single chip mode using bdm a secured mcu can be unsecured in special single chip mode by using the following method to erase the p-flash and eeprom memory: 1. reset the mcu into special single chip mode 2. delay while the bdm executes the erase verify all blocks command write sequence to check if the p-flash and eeprom memories are erased 3. send bdm commands to disable protection in the p-flash and eeprom memory 4. execute the erase all blocks command write sequence to erase the p-flash and eeprom memory. alternatively the unsecure flash command can be executed, if so the steps 5 and 6 below are skeeped. 5. after the ccif ?g sets to indicate that the erase all blocks operation has completed, reset the mcu into special single chip mode 6. delay while the bdm executes the erase verify all blocks command write sequence to verify that the p-flash and eeprom memory are erased if the p-flash and eeprom memory are veri?d as erased, the mcu will be unsecured. all bdm commands will now be enabled and the flash security byte may be programmed to the unsecure state by continuing with the following steps: 7. send bdm commands to execute the program p-flash command write sequence to program the flash security byte to the unsecured state
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1033 8. reset the mcu 28.5.3 mode and security effects on flash command availability the availability of flash module commands depends on the mcu operating mode and security state as shown in table 28-27 . 28.6 initialization on each system reset the ?sh module executes an initialization sequence which establishes initial values for the flash block con?uration parameters, the fprot and eeprot protection registers, and the fopt and fsec registers. the initialization routine reverts to built-in default values that leave the module in a fully protected and secured state if errors are encountered during execution of the reset sequence. if a double bit fault is detected during the reset sequence, both mgstat bits in the fstat register will be set. ccif is cleared throughout the initialization sequence. the flash module holds off all cpu access for a portion of the initialization sequence. flash reads are allowed once the hold is removed. completion of the initialization sequence is marked by setting ccif high which enables user commands. if a reset occurs while any flash command is in progress, that command will be immediately aborted. the state of the word being programmed or the sector/block being erased is not guaranteed.
96 kbyte flash module (s12ftmrg96k1v1) mc9s12g family reference manual, rev.1.23 1034 freescale semiconductor
mc9s12g family reference manual, rev.1.23 freescale semiconductor 1035 chapter 29 128 kbyte flash module (s12ftmrg128k1v1) 29.1 introduction the ftmrg128k1 module implements the following: 128kbytes of p-flash (program flash) memory 4 kbytes of eeprom memory the flash memory is ideal for single-supply applications allowing for ?ld reprogramming without requiring external high voltage sources for program or erase operations. the flash module includes a memory controller that executes commands to modify flash memory contents. the user interface to the memory controller consists of the indexed flash common command object (fccob) register which is written to with the command, global address, data, and any required command parameters. the memory controller must complete the execution of a command before the fccob register can be written to with a new command. caution a flash word or phrase must be in the erased state before being programmed. cumulative programming of bits within a flash word or phrase is not allowed. table 29-1. revision history revision number revision date sections affected description of changes v01.11 17 jun 2010 29.4.6.1/29-106 8 29.4.6.2/29-106 9 29.4.6.3/29-106 9 29.4.6.14/29-10 79 clarify erase verify commands descriptions related to the bits mgstat[1:0] of the register fstat. v01.12 31 aug 2010 29.4.6.2/29-106 9 29.4.6.12/29-10 76 29.4.6.13/29-10 78 updated description of the commands rd1blk, mloadu and mloadf rev.1.23 31 jan 2011 29.3.2.9/29-105 2 updated description of protection on section 29.3.2.9
mc9s12g family reference manual, rev.1.23 freescale semiconductor 1036 the flash memory may be read as bytes and aligned words. read access time is one bus cycle for bytes and aligned words. for misaligned words access, the cpu has to perform twice the byte read access command. for flash memory, an erased bit reads 1 and a programmed bit reads 0. it is possible to read from p-flash memory while some commands are executing on eeprom memory. it is not possible to read from eeprom memory while a command is executing on p-flash memory. simultaneous p-flash and eeprom operations are discussed in section 29.4.5 . both p-flash and eeprom memories are implemented with error correction codes (ecc) that can resolve single bit faults and detect double bit faults. for p-flash memory, the ecc implementation requires that programming be done on an aligned 8 byte basis (a flash phrase). since p-flash memory is always read by half-phrase, only one single bit fault in an aligned 4 byte half-phrase containing the byte or word accessed will be corrected. 29.1.1 glossary command write sequence ?an mcu instruction sequence to execute built-in algorithms (including program and erase) on the flash memory. eeprom memory ?the eeprom memory constitutes the nonvolatile memory store for data. eeprom sector ?the eeprom sector is the smallest portion of the eeprom memory that can be erased. the eeprom sector consists of 4 bytes. nvm command mode an nvm mode using the cpu to setup the fccob register to pass parameters required for flash command execution. phrase ?an aligned group of four 16-bit words within the p-flash memory. each phrase includes two sets of aligned double words with each set including 7 ecc bits for single bit fault correction and double bit fault detection within each double word. p-flash memory the p-flash memory constitutes the main nonvolatile memory store for applications. p-flash sector ?the p-flash sector is the smallest portion of the p-flash memory that can be erased. each p-flash sector contains 512 bytes. program ifr ?nonvolatile information register located in the p-flash block that contains the version id, and the program once ?ld. 29.1.2 features 29.1.2.1 p-flash features 128 kbytes of p-flash memory composed of one 128 kbyte flash block divided into 256 sectors of 512 bytes
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1037 single bit fault correction and double bit fault detection within a 32-bit double word during read operations automated program and erase algorithm with verify and generation of ecc parity bits fast sector erase and phrase program operation ability to read the p-flash memory while programming a word in the eeprom memory flexible protection scheme to prevent accidental program or erase of p-flash memory 29.1.2.2 eeprom features 4 kbytes of eeprom memory composed of one 4 kbyte flash block divided into 1024 sectors of 4 bytes single bit fault correction and double bit fault detection within a word during read operations automated program and erase algorithm with verify and generation of ecc parity bits fast sector erase and word program operation protection scheme to prevent accidental program or erase of eeprom memory ability to program up to four words in a burst sequence 29.1.2.3 other flash module features no external high-voltage power supply required for flash memory program and erase operations interrupt generation on flash command completion and flash error detection security mechanism to prevent unauthorized access to the flash memory 29.1.3 block diagram the block diagram of the flash module is shown in figure 29-1 .
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 1038 freescale semiconductor figure 29-1. ftmrg128k1 block diagram 29.2 external signal description the flash module contains no signals that connect off-chip. bus clock divider clock command interrupt request fclk protection security registers flash interface 16bit internal bus sector 0 sector 1 sector 255 32kx39 p-flash error interrupt request cpu sector 0 sector 1 sector 1023 2kx22 eeprom memory controller
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1039 29.3 memory map and registers this section describes the memory map and registers for the flash module. read data from unimplemented memory space in the flash module is unde?ed. write access to unimplemented or reserved memory space in the flash module will be ignored by the flash module. caution writing to the flash registers while a flash command is executing (that is indicated when the value of ?g ccif reads as ?? is not allowed. if such action is attempted the write operation will not change the register value. writing to the flash registers is allowed when the flash is not busy executing commands (ccif = 1) and during initialization right after reset, despite the value of ?g ccif in that case (refer to section 29.6 for a complete description of the reset sequence). . 29.3.1 module memory map the s12 architecture places the p-flash memory between global addresses 0x2_0000 and 0x3_ffff as shown in table 29-3 .the p-flash memory map is shown in figure 29-2 . table 29-2. ftmrg memory map global address (in bytes) size (bytes) description 0x0_0000 - 0x0_03ff 1,024 register space 0x0_0400 ?0x0_13ff 4,096 eeprom memory 0x0_4000 ?0x0_7fff 16,284 nvmres 1 =1 : nvm resource area (see figure 29-3 ) 1 see nvmres description in section 29.4.3 0x2_0000 ?0x3_ffff 131,072 p-flash memory table 29-3. p-flash memory addressing global address size (bytes) description 0x2_0000 ?0x3_ffff 128 k p-flash block contains flash con?uration field (see table 29-4 )
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 1040 freescale semiconductor the fprot register, described in section 29.3.2.9 , can be set to protect regions in the flash memory from accidental program or erase. three separate memory regions, one growing upward from global address 0x3_8000 in the flash memory (called the lower region), one growing downward from global address 0x3_ffff in the flash memory (called the higher region), and the remaining addresses in the flash memory, can be activated for protection. the flash memory addresses covered by these protectable regions are shown in the p-flash memory map. the higher address region is mainly targeted to hold the boot loader code since it covers the vector space. default protection settings as well as security information that allows the mcu to restrict access to the flash module are stored in the flash con?uration ?ld as described in table 29-4 . table 29-4. flash con?uration field global address size (bytes) description 0x3_ff00-0x3_ff07 8 backdoor comparison key refer to section 29.4.6.11, ?erify backdoor access key command , and section 29.5.1, ?nsecuring the mcu using backdoor key access 0x3_ff08-0x3_ff0b 1 1 0x3ff08-0x3_ff0f form a flash phrase and must be programmed in a single command write sequence. each byte in the 0x3_ff08 - 0x3_ff0b reserved ?ld should be programmed to 0xff. 4 reserved 0x3_ff0c 1 1 p-flash protection byte . refer to section 29.3.2.9, ?-flash protection register (fprot) 0x3_ff0d 1 1 eeprom protection byte . refer to section 29.3.2.10, ?eprom protection register (dfprot) 0x3_ff0e 1 1 flash nonvolatile byte refer to section 29.3.2.16, ?lash option register (fopt) 0x3_ff0f 1 1 flash security byte refer to section 29.3.2.2, ?lash security register (fsec)
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1041 figure 29-2. p-flash memory map table 29-5. program ifr fields global address size (bytes) field description 0x0_4000 ?0x0_4007 8 reserved 0x0_4008 ?0x0_40b5 174 reserved 0x0_40b6 ?0x0_40b7 2 version id 1 flash con?uration field 0x3_c000 flash protected/unprotected lower region 1, 2, 4, 8 kbytes 0x3_8000 0x3_9000 0x3_8400 0x3_8800 0x3_a000 p-flash end = 0x3_ffff 0x3_f800 0x3_f000 0x3_e000 flash protected/unprotected higher region 2, 4, 8, 16 kbytes flash protected/unprotected region 8 kbytes (up to 29 kbytes) 16 bytes (0x3_ff00 - 0x3_ff0f) flash protected/unprotected region 96 kbytes p-flash start = 0x2_0000 protection protection protection movable end fixed end fixed end
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 1042 freescale semiconductor figure 29-3. memory controller resource memory map (nvmres=1) 0x0_40b8 ?0x0_40bf 8 reserved 0x0_40c0 ?0x0_40ff 64 program once field refer to section 29.4.6.6, ?rogram once command 1 used to track ?mware patch versions, see section 29.4.2 table 29-6. memory controller resource fields (nvmres 1 =1) 1 nvmres - see section 29.4.3 for nvmres (nvm resource) detail. global address size (bytes) description 0x0_4000 ?0x040ff 256 p-flash ifr (see table 29-5 ) 0x0_4100 ?0x0_41ff 256 reserved. 0x0_4200 ?0x0_57ff reserved 0x0_5800 ?0x0_59ff 512 reserved 0x0_5a00 ?0x0_5fff 1,536 reserved 0x0_6000 ?0x0_6bff 3,072 reserved 0x0_6c00 ?0x0_7fff 5,120 reserved table 29-5. program ifr fields global address size (bytes) field description p-flash ifr 1 kbyte (nvmres=1) 0x0_4000 ram end = 0x0_59ff ram start = 0x0_5800 reserved 5120 bytes reserved 4608 bytes 0x0_6c00 0x0_7fff 0x0_4400 reserved 5k bytes reserved 512 bytes
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1043 29.3.2 register descriptions the flash module contains a set of 20 control and status registers located between flash module base + 0x0000 and 0x0013. in the case of the writable registers, the write accesses are forbidden during fash command execution (for more detail, see caution note in section 29.3 ). a summary of the flash module registers is given in figure 29-4 with detailed descriptions in the following subsections. address & name 76543210 0x0000 fclkdiv r fdivld fdivlck fdiv5 fdiv4 fdiv3 fdiv2 fdiv1 fdiv0 w 0x0001 fsec r keyen1 keyen0 rnv5 rnv4 rnv3 rnv2 sec1 sec0 w 0x0002 fccobix r0 0 0 0 0 ccobix2 ccobix1 ccobix0 w 0x0003 frsv0 r00000000 w 0x0004 fcnfg r ccie 00 ignsf 00 fdfd fsfd w 0x0005 fercnfg r0 0 0 0 0 0 dfdie sfdie w 0x0006 fstat r ccif 0 accerr fpviol mgbusy rsvd mgstat1 mgstat0 w 0x0007 ferstat r0 0 0 0 0 0 dfdif sfdif w 0x0008 fprot r fpopen rnv6 fphdis fphs1 fphs0 fpldis fpls1 fpls0 w 0x0009 dfprot r dpopen dps6 dps5 dps4 dps3 dps2 dps1 dps0 w figure 29-4. ftmrg128k1 register summary
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 1044 freescale semiconductor 29.3.2.1 flash clock divider register (fclkdiv) the fclkdiv register is used to control timed events in program and erase algorithms. 0x000a fccobhi r ccob15 ccob14 ccob13 ccob12 ccob11 ccob10 ccob9 ccob8 w 0x000b fccoblo r ccob7 ccob6 ccob5 ccob4 ccob3 ccob2 ccob1 ccob0 w 0x000c frsv1 r00000000 w 0x000d frsv2 r00000000 w 0x000e frsv3 r00000000 w 0x000f frsv4 r00000000 w 0x0010 fopt r nv7 nv6 nv5 nv4 nv3 nv2 nv1 nv0 w 0x0011 frsv5 r00000000 w 0x0012 frsv6 r00000000 w 0x0013 frsv7 r00000000 w = unimplemented or reserved address & name 76543210 figure 29-4. ftmrg128k1 register summary (continued)
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1045 all bits in the fclkdiv register are readable, bit 7 is not writable, bit 6 is write-once-hi and controls the writability of the fdiv ?ld in normal mode. in special mode, bits 6-0 are writable any number of times but bit 7 remains unwritable. caution the fclkdiv register should never be written while a flash command is executing (ccif=0). offset module base + 0x0000 76543210 r fdivld fdivlck fdiv[5:0] w reset 00000000 = unimplemented or reserved figure 29-5. flash clock divider register (fclkdiv) table 29-7. fclkdiv field descriptions field description 7 fdivld clock divider loaded 0 fclkdiv register has not been written since the last reset 1 fclkdiv register has been written since the last reset 6 fdivlck clock divider locked 0 fdiv ?ld is open for writing 1 fdiv value is locked and cannot be changed. once the lock bit is set high, only reset can clear this bit and restore writability to the fdiv ?ld in normal mode. 5? fdiv[5:0] clock divider bits fdiv[5:0] must be set to effectively divide busclk down to 1 mhz to control timed events during flash program and erase algorithms. table 29-8 shows recommended values for fdiv[5:0] based on the busclk frequency. please refer to section 29.4.4, ?lash command operations , for more information.
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 1046 freescale semiconductor 29.3.2.2 flash security register (fsec) the fsec register holds all bits associated with the security of the mcu and flash module. all bits in the fsec register are readable but not writable. during the reset sequence, the fsec register is loaded with the contents of the flash security byte in the flash con?uration ?ld at global address 0x3_ff0f located in p-flash memory (see table 29-4 ) as table 29-8. fdiv values for various busclk frequencies busclk frequency (mhz) fdiv[5:0] busclk frequency (mhz) fdiv[5:0] min 1 1 busclk is greater than this value. max 2 2 busclk is less than or equal to this value. min 1 max 2 1.0 1.6 0x00 16.6 17.6 0x10 1.6 2.6 0x01 17.6 18.6 0x11 2.6 3.6 0x02 18.6 19.6 0x12 3.6 4.6 0x03 19.6 20.6 0x13 4.6 5.6 0x04 20.6 21.6 0x14 5.6 6.6 0x05 21.6 22.6 0x15 6.6 7.6 0x06 22.6 23.6 0x16 7.6 8.6 0x07 23.6 24.6 0x17 8.6 9.6 0x08 24.6 25.6 0x18 9.6 10.6 0x09 10.6 11.6 0x0a 11.6 12.6 0x0b 12.6 13.6 0x0c 13.6 14.6 0x0d 14.6 15.6 0x0e 15.6 16.6 0x0f offset module base + 0x0001 76543210 r keyen[1:0] rnv[5:2] sec[1:0] w reset f 1 1 loaded from ifr flash con?uration ?ld, during reset sequence. f 1 f 1 f 1 f 1 f 1 f 1 f 1 = unimplemented or reserved figure 29-6. flash security register (fsec)
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1047 indicated by reset condition f in figure 29-6 . if a double bit fault is detected while reading the p-flash phrase containing the flash security byte during the reset sequence, all bits in the fsec register will be set to leave the flash module in a secured state with backdoor key access disabled. the security function in the flash module is described in section 29.5 . 29.3.2.3 flash ccob index register (fccobix) the fccobix register is used to index the fccob register for flash memory operations. table 29-9. fsec field descriptions field description 7? keyen[1:0] backdoor key security enable bits the keyen[1:0] bits de?e the enabling of backdoor key access to the flash module as shown in table 29-10 . 5? rnv[5:2] reserved nonvolatile bits ?the rnv bits should remain in the erased state for future enhancements. 1? sec[1:0] flash security bits ?the sec[1:0] bits de?e the security state of the mcu as shown in table 29-11 . if the flash module is unsecured using backdoor key access, the sec bits are forced to 10. table 29-10. flash keyen states keyen[1:0] status of backdoor key access 00 disabled 01 disabled 1 1 preferred keyen state to disable backdoor key access. 10 enabled 11 disabled table 29-11. flash security states sec[1:0] status of security 00 secured 01 secured 1 1 preferred sec state to set mcu to secured state. 10 unsecured 11 secured offset module base + 0x0002 76543210 r00000 ccobix[2:0] w reset 00000000 = unimplemented or reserved figure 29-7. fccob index register (fccobix)
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 1048 freescale semiconductor ccobix bits are readable and writable while remaining bits read 0 and are not writable. 29.3.2.4 flash reserved0 register (frsv0) this flash register is reserved for factory testing. all bits in the frsv0 register read 0 and are not writable. 29.3.2.5 flash con?uration register (fcnfg) the fcnfg register enables the flash command complete interrupt and forces ecc faults on flash array read access from the cpu. ccie, ignsf, fdfd, and fsfd bits are readable and writable while remaining bits read 0 and are not writable. table 29-12. fccobix field descriptions field description 2? ccobix[1:0] common command register index the ccobix bits are used to select which word of the fccob register array is being read or written to. see 29.3.2.11 flash common command object register (fccob), for more details. offset module base + 0x000c 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 29-8. flash reserved0 register (frsv0) offset module base + 0x0004 76543210 r ccie 00 ignsf 00 fdfd fsfd w reset 00000000 = unimplemented or reserved figure 29-9. flash con?uration register (fcnfg)
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1049 29.3.2.6 flash error con?uration register (fercnfg) the fercnfg register enables the flash error interrupts for the ferstat ?gs. all assigned bits in the fercnfg register are readable and writable. table 29-13. fcnfg field descriptions field description 7 ccie command complete interrupt enable ?the ccie bit controls interrupt generation when a flash command has completed. 0 command complete interrupt disabled 1 an interrupt will be requested whenever the ccif ?g in the fstat register is set (see section 29.3.2.7 ) 4 ignsf ignore single bit fault ?the ignsf controls single bit fault reporting in the ferstat register (see section 29.3.2.8 ). 0 all single bit faults detected during array reads are reported 1 single bit faults detected during array reads are not reported and the single bit fault interrupt will not be generated 1 fdfd force double bit fault detect the fdfd bit allows the user to simulate a double bit fault during flash array read operations and check the associated interrupt routine. the fdfd bit is cleared by writing a 0 to fdfd. 0 flash array read operations will set the dfdif ?g in the ferstat register only if a double bit fault is detected 1 any flash array read operation will force the dfdif ?g in the ferstat register to be set (see section 29.3.2.7 ) and an interrupt will be generated as long as the dfdie interrupt enable in the fercnfg register is set (see section 29.3.2.6 ) 0 fsfd force single bit fault detect the fsfd bit allows the user to simulate a single bit fault during flash array read operations and check the associated interrupt routine. the fsfd bit is cleared by writing a 0 to fsfd. 0 flash array read operations will set the sfdif ?g in the ferstat register only if a single bit fault is detected 1 flash array read operation will force the sfdif ?g in the ferstat register to be set (see section 29.3.2.7 ) and an interrupt will be generated as long as the sfdie interrupt enable in the fercnfg register is set (see section 29.3.2.6 ) offset module base + 0x0005 76543210 r000000 dfdie sfdie w reset 00000000 = unimplemented or reserved figure 29-10. flash error con?uration register (fercnfg)
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 1050 freescale semiconductor 29.3.2.7 flash status register (fstat) the fstat register reports the operational status of the flash module. ccif, accerr, and fpviol bits are readable and writable, mgbusy and mgstat bits are readable but not writable, while remaining bits read 0 and are not writable. table 29-14. fercnfg field descriptions field description 1 dfdie double bit fault detect interrupt enable the dfdie bit controls interrupt generation when a double bit fault is detected during a flash block read operation. 0 dfdif interrupt disabled 1 an interrupt will be requested whenever the dfdif ?g is set (see section 29.3.2.8 ) 0 sfdie single bit fault detect interrupt enable the sfdie bit controls interrupt generation when a single bit fault is detected during a flash block read operation. 0 sfdif interrupt disabled whenever the sfdif ?g is set (see section 29.3.2.8 ) 1 an interrupt will be requested whenever the sfdif ?g is set (see section 29.3.2.8 ) offset module base + 0x0006 76543210 r ccif 0 accerr fpviol mgbusy rsvd mgstat[1:0] w reset 1000000 1 1 reset value can deviate from the value shown if a double bit fault is detected during the reset sequence (see section 29.6 ). 0 1 = unimplemented or reserved figure 29-11. flash status register (fstat) table 29-15. fstat field descriptions field description 7 ccif command complete interrupt flag ?the ccif ?g indicates that a flash command has completed. the ccif ?g is cleared by writing a 1 to ccif to launch a command and ccif will stay low until command completion or command violation. 0 flash command in progress 1 flash command has completed 5 accerr flash access error flag ?the accerr bit indicates an illegal access has occurred to the flash memory caused by either a violation of the command write sequence (see section 29.4.4.2 ) or issuing an illegal flash command. while accerr is set, the ccif ?g cannot be cleared to launch a command. the accerr bit is cleared by writing a 1 to accerr. writing a 0 to the accerr bit has no effect on accerr. 0 no access error detected 1 access error detected 4 fpviol flash protection violation flag ?he fpviol bit indicates an attempt was made to program or erase an address in a protected area of p-flash or eeprom memory during a command write sequence. the fpviol bit is cleared by writing a 1 to fpviol. writing a 0 to the fpviol bit has no effect on fpviol. while fpviol is set, it is not possible to launch a command or start a command write sequence. 0 no protection violation detected 1 protection violation detected
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1051 29.3.2.8 flash error status register (ferstat) the ferstat register re?cts the error status of internal flash operations. all ?gs in the ferstat register are readable and only writable to clear the ?g. 3 mgbusy memory controller busy flag ?the mgbusy ?g re?cts the active state of the memory controller . 0 memory controller is idle 1 memory controller is busy executing a flash command (ccif = 0) 2 rsvd reserved bit ?this bit is reserved and always reads 0 . 1? mgstat[1:0] memory controller command completion status flag one or more mgstat ?g bits are set if an error is detected during execution of a flash command or during the flash reset sequence. see section 29.4.6, ?lash command description , and section 29.6, ?nitialization ?for details. offset module base + 0x0007 76543210 r000000 dfdif sfdif w reset 00000000 = unimplemented or reserved figure 29-12. flash error status register (ferstat) table 29-16. ferstat field descriptions field description 1 dfdif double bit fault detect interrupt flag ?the setting of the dfdif ?g indicates that a double bit fault was detected in the stored parity and data bits during a flash array read operation or that a flash array read operation returning invalid data was attempted on a flash block that was under a flash command operation. 1 the dfdif ?g is cleared by writing a 1 to dfdif. writing a 0 to dfdif has no effect on dfdif. 2 0 no double bit fault detected 1 double bit fault detected or a flash array read operation returning invalid data was attempted while command running 1 the single bit fault and double bit fault ?gs are mutually exclusive for parity errors (an ecc fault occurrence can be either single fault or double fault but never both). a simultaneous access collision (flash array read operation returning invalid data attempted while command running) is indicated when both sfdif and dfdif ?gs are high. 2 there is a one cycle delay in storing the ecc dfdif and sfdif fault ?gs in this register. at least one nop is required after a ?sh memory read before checking ferstat for the occurrence of ecc errors. 0 sfdif single bit fault detect interrupt flag ?with the ignsf bit in the fcnfg register clear, the sfdif ?g indicates that a single bit fault was detected in the stored parity and data bits during a flash array read operation or that a flash array read operation returning invalid data was attempted on a flash block that was under a flash command operation. 1 the sfdif ?g is cleared by writing a 1 to sfdif. writing a 0 to sfdif has no effect on sfdif. 0 no single bit fault detected 1 single bit fault detected and corrected or a flash array read operation returning invalid data was attempted while command running table 29-15. fstat field descriptions (continued) field description
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 1052 freescale semiconductor 29.3.2.9 p-flash protection register (fprot) the fprot register de?es which p-flash sectors are protected against program and erase operations. the (unreserved) bits of the fprot register are writable with the restriction that the size of the protected region can only be increased (see section 29.3.2.9.1, ?-flash protection restrictions , and table 29-21 ). during the reset sequence, the fprot register is loaded with the contents of the p-flash protection byte in the flash con?uration ?ld at global address 0x3_ff0c located in p-flash memory (see table 29-4 ) as indicated by reset condition ??in figure 29-13 . to change the p-flash protection that will be loaded during the reset sequence, the upper sector of the p-flash memory must be unprotected, then the p-flash protection byte must be reprogrammed. if a double bit fault is detected while reading the p-flash phrase containing the p-flash protection byte during the reset sequence, the fpopen bit will be cleared and remaining bits in the fprot register will be set to leave the p-flash memory fully protected. trying to alter data in any protected area in the p-flash memory will result in a protection violation error and the fpviol bit will be set in the fstat register. the block erase of a p-flash block is not possible if any of the p-flash sectors contained in the same p-flash block are protected. offset module base + 0x0008 76543210 r fpopen rnv6 fphdis fphs[1:0] fpldis fpls[1:0] w reset f 1 1 loaded from ifr flash con?uration ?ld, during reset sequence. f 1 f 1 f 1 f 1 f 1 f 1 f 1 = unimplemented or reserved figure 29-13. flash protection register (fprot) table 29-17. fprot field descriptions field description 7 fpopen flash protection operation enable ?the fpopen bit determines the protection function for program or erase operations as shown in table 29-18 for the p-flash block. 0 when fpopen is clear, the fphdis and fpldis bits de?e unprotected address ranges as speci?d by the corresponding fphs and fpls bits 1 when fpopen is set, the fphdis and fpldis bits enable protection for the address range speci?d by the corresponding fphs and fpls bits 6 rnv[6] reserved nonvolatile bit ?the rnv bit should remain in the erased state for future enhancements. 5 fphdis flash protection higher address range disable ?the fphdis bit determines whether there is a protected/unprotected area in a speci? region of the p-flash memory ending with global address 0x3_ffff. 0 protection/unprotection enabled 1 protection/unprotection disabled 4? fphs[1:0] flash protection higher address size the fphs bits determine the size of the protected/unprotected area in p-flash memory as shown in table 29-19 . the fphs bits can only be written to while the fphdis bit is set.
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1053 all possible p-flash protection scenarios are shown in figure 29-14 . although the protection scheme is loaded from the flash memory at global address 0x3_ff0c during the reset sequence, it can be changed by the user. the p-flash protection scheme can be used by applications requiring reprogramming in single chip mode while providing as much protection as possible if reprogramming is not required. 2 fpldis flash protection lower address range disable ?the fpldis bit determines whether there is a protected/unprotected area in a speci? region of the p-flash memory beginning with global address 0x3_8000. 0 protection/unprotection enabled 1 protection/unprotection disabled 1? fpls[1:0] flash protection lower address size the fpls bits determine the size of the protected/unprotected area in p-flash memory as shown in table 29-20 . the fpls bits can only be written to while the fpldis bit is set. table 29-18. p-flash protection function fpopen fphdis fpldis function 1 1 for range sizes, refer to table 29-19 and table 29-20 . 1 1 1 no p-flash protection 1 1 0 protected low range 1 0 1 protected high range 1 0 0 protected high and low ranges 0 1 1 full p-flash memory protected 0 1 0 unprotected low range 0 0 1 unprotected high range 0 0 0 unprotected high and low ranges table 29-19. p-flash protection higher address range fphs[1:0] global address range protected size 00 0x3_f800?x3_ffff 2 kbytes 01 0x3_f000?x3_ffff 4 kbytes 10 0x3_e000?x3_ffff 8 kbytes 11 0x3_c000?x3_ffff 16 kbytes table 29-20. p-flash protection lower address range fpls[1:0] global address range protected size 00 0x3_8000?x3_83ff 1 kbyte 01 0x3_8000?x3_87ff 2 kbytes 10 0x3_8000?x3_8fff 4 kbytes 11 0x3_8000?x3_9fff 8 kbytes table 29-17. fprot field descriptions (continued) field description
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 1054 freescale semiconductor figure 29-14. p-flash protection scenarios 7 6 5 4 fphs[1:0] fpls[1:0] 3 2 1 0 fphs[1:0] fpls[1:0] fphdis = 1 fpldis = 1 fphdis = 1 fpldis = 0 fphdis = 0 fpldis = 1 fphdis = 0 fpldis = 0 scenario scenario unprotected region protected region with size protected region protected region with size defined by fpls defined by fphs not defined by fpls, fphs 0x3_8000 0x3_ffff 0x3_8000 0x3_ffff flash start flash start fpopen = 1 fpopen = 0
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1055 29.3.2.9.1 p-flash protection restrictions the general guideline is that p-flash protection can only be added and not removed. table 29-21 speci?s all valid transitions between p-flash protection scenarios. any attempt to write an invalid scenario to the fprot register will be ignored. the contents of the fprot register re?ct the active protection scenario. see the fphs and fpls bit descriptions for additional restrictions. 29.3.2.10 eeprom protection register (dfprot) the dfprot register de?es which eeprom sectors are protected against program and erase operations. the (unreserved) bits of the dfprot register are writable with the restriction that protection can be added but not removed. writes must increase the dps value and the dpopen bit can only be written from 1 (protection disabled) to 0 (protection enabled). if the dpopen bit is set, the state of the dps bits is irrelevant. during the reset sequence, ?lds dpopen and dps of the dfprot register are loaded with the contents of the eeprom protection byte in the flash configuration field at global address 0x3_ff0d located in table 29-21. p-flash protection scenario transitions from protection scenario to protection scenario 1 1 allowed transitions marked with x, see figure 29-14 for a de?ition of the scenarios. 01234567 0 xxxx 1 xx 2 xx 3 x 4 xx 5 xxxx 6 xxxx 7 xxxxxxxx offset module base + 0x0009 76543210 r dpopen dps[6:0] w reset f 1 1 loaded from ifr flash con?uration ?ld, during reset sequence. f 1 f 1 f 1 f 1 f 1 f 1 f 1 figure 29-15. eeprom protection register (dfprot)
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 1056 freescale semiconductor p-flash memory (see table 29-4 ) as indicated by reset condition f in table 29-23 . to change the eeprom protection that will be loaded during the reset sequence, the p-flash sector containing the eeprom protection byte must be unprotected, then the eeprom protection byte must be programmed. if a double bit fault is detected while reading the p-flash phrase containing the eeprom protection byte during the reset sequence, the dpopen bit will be cleared and dps bits will be set to leave the eeprom memory fully protected. trying to alter data in any protected area in the eeprom memory will result in a protection violation error and the fpviol bit will be set in the fstat register. block erase of the eeprom memory is not possible if any of the eeprom sectors are protected. table 29-22. dfprot field descriptions field description 7 dpopen eeprom protection control 0 enables eeprom memory protection from program and erase with protected address range de?ed by dps bits 1 disables eeprom memory protection from program and erase 6? dps[6:0] eeprom protection size ?the dps[6:0] bits determine the size of the protected area in the eeprom memory, this size increase in step of 32 bytes, as shown in table 29-23 . table 29-23. eeprom protection address range dps[6:0] global address range protected size 0000000 0x0_0400 ?0x0_041f 32 bytes 0000001 0x0_0400 ?0x0_043f 64 bytes 0000010 0x0_0400 ?0x0_045f 96 bytes 0000011 0x0_0400 ?0x0_047f 128 bytes 0000100 0x0_0400 ?0x0_049f 160 bytes 0000101 0x0_0400 ?0x0_04bf 192 bytes the protection size goes on enlarging in step of 32 bytes, for each dps value increasing of one. . . . 1111111 0x0_0400 ?0x0_13ff 4,096 bytes
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1057 29.3.2.11 flash common command object register (fccob) the fccob is an array of six words addressed via the ccobix index found in the fccobix register. byte wide reads and writes are allowed to the fccob register. 29.3.2.11.1 fccob - nvm command mode nvm command mode uses the indexed fccob register to provide a command code and its relevant parameters to the memory controller. the user ?st sets up all required fccob ?lds and then initiates the commands execution by writing a 1 to the ccif bit in the fstat register (a 1 written by the user clears the ccif command completion ?g to 0). when the user clears the ccif bit in the fstat register all fccob parameter ?lds are locked and cannot be changed by the user until the command completes (as evidenced by the memory controller returning ccif to 1). some commands return information to the fccob register array. the generic format for the fccob parameter ?lds in nvm command mode is shown in table 29-24 . the return values are available for reading after the ccif ?g in the fstat register has been returned to 1 by the memory controller. writes to the unimplemented parameter ?lds (ccobix = 110 and ccobix = 111) are ignored with reads from these ?lds returning 0x0000. table 29-24 shows the generic flash command format. the high byte of the ?st word in the ccob array contains the command code, followed by the parameters for this speci? flash command. for details on the fccob settings required by each command, see the flash command descriptions in section 29.4.6 . offset module base + 0x000a 76543210 r ccob[15:8] w reset 00000000 figure 29-16. flash common command object high register (fccobhi) offset module base + 0x000b 76543210 r ccob[7:0] w reset 00000000 figure 29-17. flash common command object low register (fccoblo) table 29-24. fccob - nvm command mode (typical usage) ccobix[2:0] byte fccob parameter fields (nvm command mode) 000 hi fcmd[7:0] de?ing flash command lo 6?0, global address [17:16] 001 hi global address [15:8] lo global address [7:0]
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 1058 freescale semiconductor 29.3.2.12 flash reserved1 register (frsv1) this flash register is reserved for factory testing. all bits in the frsv1 register read 0 and are not writable. 29.3.2.13 flash reserved2 register (frsv2) this flash register is reserved for factory testing. all bits in the frsv2 register read 0 and are not writable. 29.3.2.14 flash reserved3 register (frsv3) this flash register is reserved for factory testing. 010 hi data 0 [15:8] lo data 0 [7:0] 011 hi data 1 [15:8] lo data 1 [7:0] 100 hi data 2 [15:8] lo data 2 [7:0] 101 hi data 3 [15:8] lo data 3 [7:0] offset module base + 0x000c 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 29-18. flash reserved1 register (frsv1) offset module base + 0x000d 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 29-19. flash reserved2 register (frsv2) table 29-24. fccob - nvm command mode (typical usage) ccobix[2:0] byte fccob parameter fields (nvm command mode)
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1059 all bits in the frsv3 register read 0 and are not writable. 29.3.2.15 flash reserved4 register (frsv4) this flash register is reserved for factory testing. all bits in the frsv4 register read 0 and are not writable. 29.3.2.16 flash option register (fopt) the fopt register is the flash option register. all bits in the fopt register are readable but are not writable. during the reset sequence, the fopt register is loaded from the flash nonvolatile byte in the flash con?uration ?ld at global address 0x3_ff0e located in p-flash memory (see table 29-4 ) as indicated by reset condition f in figure 29-22 . if a double bit fault is detected while reading the p-flash phrase containing the flash nonvolatile byte during the reset sequence, all bits in the fopt register will be set. offset module base + 0x000e 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 29-20. flash reserved3 register (frsv3) offset module base + 0x000f 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 29-21. flash reserved4 register (frsv4) offset module base + 0x0010 76543210 r nv[7:0] w reset f 1 1 loaded from ifr flash con?uration ?ld, during reset sequence. f 1 f 1 f 1 f 1 f 1 f 1 f 1 = unimplemented or reserved figure 29-22. flash option register (fopt)
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 1060 freescale semiconductor 29.3.2.17 flash reserved5 register (frsv5) this flash register is reserved for factory testing. all bits in the frsv5 register read 0 and are not writable. 29.3.2.18 flash reserved6 register (frsv6) this flash register is reserved for factory testing. all bits in the frsv6 register read 0 and are not writable. 29.3.2.19 flash reserved7 register (frsv7) this flash register is reserved for factory testing. table 29-25. fopt field descriptions field description 7? nv[7:0] nonvolatile bits the nv[7:0] bits are available as nonvolatile bits. refer to the device user guide for proper use of the nv bits. offset module base + 0x0011 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 29-23. flash reserved5 register (frsv5) offset module base + 0x0012 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 29-24. flash reserved6 register (frsv6)
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1061 all bits in the frsv7 register read 0 and are not writable. 29.4 functional description 29.4.1 modes of operation the ftmrg128k1 module provides the modes of operation normal and special . the operating mode is determined by module-level inputs and affects the fclkdiv, fcnfg, and dfprot registers (see table 29-27 ). 29.4.2 ifr version id word the version id word is stored in the ifr at address 0x0_40b6. the contents of the word are de?ed in table 29-26 . vernum: version number. the ?st version is number 0b_0001 with both 0b_0000 and 0b_1111 meaning ?one? offset module base + 0x0013 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 29-25. flash reserved7 register (frsv7) table 29-26. ifr version id fields [15:4] [3:0] reserved vernum
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 1062 freescale semiconductor 29.4.3 internal nvm resource (nvmres) ifr is an internal nvm resource readable by cpu , when nvmres is active. the ifr ?lds are shown in table 29-5 . the nvmres global address map is shown in table 29-6 . 29.4.4 flash command operations flash command operations are used to modify flash memory contents. the next sections describe: how to write the fclkdiv register that is used to generate a time base (fclk) derived from busclk for flash program and erase command operations the command write sequence used to set flash command parameters and launch execution valid flash commands available for execution, according to mcu functional mode and mcu security state. 29.4.4.1 writing the fclkdiv register prior to issuing any flash program or erase command after a reset, the user is required to write the fclkdiv register to divide busclk down to a target fclk of 1 mhz. table 29-8 shows recommended values for the fdiv ?ld based on busclk frequency. note programming or erasing the flash memory cannot be performed if the bus clock runs at less than 0.8 mhz. setting fdiv too high can destroy the flash memory due to overstress. setting fdiv too low can result in incomplete programming or erasure of the flash memory cells. when the fclkdiv register is written, the fdivld bit is set automatically. if the fdivld bit is 0, the fclkdiv register has not been written since the last reset. if the fclkdiv register has not been written, any flash program or erase command loaded during a command write sequence will not execute and the accerr bit in the fstat register will set. 29.4.4.2 command write sequence the memory controller will launch all valid flash commands entered using a command write sequence. before launching a command, the accerr and fpviol bits in the fstat register must be clear (see section 29.3.2.7 ) and the ccif ?g should be tested to determine the status of the current command write sequence. if ccif is 0, the previous command write sequence is still active, a new command write sequence cannot be started, and all writes to the fccob register are ignored.
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1063 29.4.4.2.1 de?e fccob contents the fccob parameter ?lds must be loaded with all required parameters for the flash command being executed. access to the fccob parameter ?lds is controlled via the ccobix bits in the fccobix register (see section 29.3.2.3 ). the contents of the fccob parameter ?lds are transferred to the memory controller when the user clears the ccif command completion ?g in the fstat register (writing 1 clears the ccif to 0). the ccif ?g will remain clear until the flash command has completed. upon completion, the memory controller will return ccif to 1 and the fccob register will be used to communicate any results. the ?w for a generic command write sequence is shown in figure 29-26 .
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 1064 freescale semiconductor figure 29-26. generic flash command write sequence flowchart write to fccobix register write: fstat register (to launch command) clear ccif 0x80 clear accerr/fpviol 0x30 write: fstat register yes no access error and protection violation read: fstat register start check fccob accerr/ fpviol set? exit write: fclkdiv register read: fclkdiv register yes no fdiv correct? no bit polling for command completion check yes ccif set? to identify speci? command parameter to load. write to fccob register to load required command parameter. yes no more parameters? availability check results from previous command note: fclkdiv must be set after each reset read: fstat register no yes ccif set? no yes ccif set? clock divider value check read: fstat register
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1065 29.4.4.3 valid flash module commands table 29-27 present the valid flash commands, as enabled by the combination of the functional mcu mode (normal singlechip ns, special singlechip ss) with the mcu security state (unsecured, secured). special singlechip mode is selected by input mmc_ss_mode_ts2 asserted. mcu secured state is selected by input mmc_secure input asserted. + 29.4.4.4 p-flash commands table 29-28 summarizes the valid p-flash commands along with the effects of the commands on the p-flash block and other resources within the flash module. table 29-27. flash commands by mode and security state fcmd command unsecured secured ns 1 1 unsecured normal single chip mode ss 2 2 unsecured special single chip mode. ns 3 3 secured normal single chip mode. ss 4 4 secured special single chip mode. 0x01 erase verify all blocks ???? 0x02 erase verify block ???? 0x03 erase verify p-flash section ??? 0x04 read once ??? 0x06 program p-flash ??? 0x07 program once ??? 0x08 erase all blocks ?? 0x09 erase flash block ??? 0x0a erase p-flash sector ??? 0x0b unsecure flash ?? 0x0c verify backdoor access key ?? 0x0d set user margin level ??? 0x0e set field margin level ? 0x10 erase verify eeprom section ??? 0x11 program eeprom ??? 0x12 erase eeprom sector ??? table 29-28. p-flash commands fcmd command function on p-flash memory 0x01 erase verify all blocks verify that all p-flash (and eeprom) blocks are erased.
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 1066 freescale semiconductor 29.4.4.5 eeprom commands table 29-29 summarizes the valid eeprom commands along with the effects of the commands on the eeprom block. 0x02 erase verify block verify that a p-flash block is erased. 0x03 erase verify p-flash section verify that a given number of words starting at the address provided are erased. 0x04 read once read a dedicated 64 byte ?ld in the nonvolatile information register in p-flash block that was previously programmed using the program once command. 0x06 program p-flash program a phrase in a p-flash block. 0x07 program once program a dedicated 64 byte ?ld in the nonvolatile information register in p-flash block that is allowed to be programmed only once. 0x08 erase all blocks erase all p-flash (and eeprom) blocks. an erase of all flash blocks is only possible when the fpldis, fphdis, and fpopen bits in the fprot register and the dpopen bit in the dfprot register are set prior to launching the command. 0x09 erase flash block erase a p-flash (or eeprom) block. an erase of the full p-flash block is only possible when fpldis, fphdis and fpopen bits in the fprot register are set prior to launching the command. 0x0a erase p-flash sector erase all bytes in a p-flash sector. 0x0b unsecure flash supports a method of releasing mcu security by erasing all p-flash (and eeprom) blocks and verifying that all p-flash (and eeprom) blocks are erased. 0x0c verify backdoor access key supports a method of releasing mcu security by verifying a set of security keys. 0x0d set user margin level speci?s a user margin read level for all p-flash blocks. 0x0e set field margin level speci?s a ?ld margin read level for all p-flash blocks (special modes only). table 29-29. eeprom commands fcmd command function on eeprom memory 0x01 erase verify all blocks verify that all eeprom (and p-flash) blocks are erased. 0x02 erase verify block verify that the eeprom block is erased. table 29-28. p-flash commands fcmd command function on p-flash memory
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1067 29.4.5 allowed simultaneous p-flash and eeprom operations only the operations marked ?k?in table 29-30 are permitted to be run simultaneously on the program flash and eeprom blocks. some operations cannot be executed simultaneously because certain hardware resources are shared by the two memories. the priority has been placed on permitting program flash reads while program and erase operations execute on the eeprom, providing read (p-flash) while write (eeprom) functionality. 0x08 erase all blocks erase all eeprom (and p-flash) blocks. an erase of all flash blocks is only possible when the fpldis, fphdis, and fpopen bits in the fprot register and the dpopen bit in the dfprot register are set prior to launching the command. 0x09 erase flash block erase a eeprom (or p-flash) block. an erase of the full eeprom block is only possible when dpopen bit in the dfprot register is set prior to launching the command. 0x0b unsecure flash supports a method of releasing mcu security by erasing all eeprom (and p-flash) blocks and verifying that all eeprom (and p-flash) blocks are erased. 0x0d set user margin level speci?s a user margin read level for the eeprom block. 0x0e set field margin level speci?s a ?ld margin read level for the eeprom block (special modes only). 0x10 erase verify eeprom section verify that a given number of words starting at the address provided are erased. 0x11 program eeprom program up to four words in the eeprom block. 0x12 erase eeprom sector erase all bytes in a sector of the eeprom block. table 29-30. allowed p-flash and eeprom simultaneous operations eeprom program flash read margin read 1 program sector erase mass erase 2 read ok ok ok margin read 1 1 a ?argin read?is any read after executing the margin setting commands ?et user margin level?or ?et field margin level?with anything but the ?ormal level speci?d. see the note on margin settings in section 29.4.6.12 and section 29.4.6.13 . program sector erase mass erase 2 2 the ?ass erase?operations are commands ?rase all blocks?and ?rase flash block ok table 29-29. eeprom commands fcmd command function on eeprom memory
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 1068 freescale semiconductor 29.4.6 flash command description this section provides details of all available flash commands launched by a command write sequence. the accerr bit in the fstat register will be set during the command write sequence if any of the following illegal steps are performed, causing the command not to be processed by the memory controller: starting any command write sequence that programs or erases flash memory before initializing the fclkdiv register writing an invalid command as part of the command write sequence for additional possible errors, refer to the error handling table provided for each command if a flash block is read during execution of an algorithm (ccif = 0) on that same block, the read operation will return invalid data if both ?gs sfdif and dfdif are set. if the sfdif or dfdif ?gs were not previously set when the invalid read operation occurred, both the sfdif and dfdif ?gs will be set. if the accerr or fpviol bits are set in the fstat register, the user must clear these bits before starting any command write sequence (see section 29.3.2.7 ). caution a flash word or phrase must be in the erased state before being programmed. cumulative programming of bits within a flash word or phrase is not allowed. 29.4.6.1 erase verify all blocks command the erase verify all blocks command will verify that all p-flash and eeprom blocks have been erased. upon clearing ccif to launch the erase verify all blocks command, the memory controller will verify that the entire flash memory space is erased. the ccif ?g will set after the erase verify all blocks operation has completed. if all blocks are not erased, it means blank check failed, both mgstat bits will be set. table 29-31. erase verify all blocks command fccob requirements ccobix[2:0] fccob parameters 000 0x01 not required table 29-32. erase verify all blocks command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 000 at command launch fpviol none mgstat1 set if any errors have been encountered during the reador if blank check failed . mgstat0 set if any non-correctable errors have been encountered during the read or if blank check failed.
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1069 29.4.6.2 erase verify block command the erase verify block command allows the user to verify that an entire p-flash or eeprom block has been erased. the fccob flashblockselectioncode[1:0] bits determine which block must be veri?d. upon clearing ccif to launch the erase verify block command, the memory controller will verify that the selected p-flash or eeprom block is erased. the ccif ?g will set after the erase verify block operation has completed.if the block is not erased, it means blank check failed, both mgstat bits will be set. 29.4.6.3 erase verify p-flash section command the erase verify p-flash section command will verify that a section of code in the p-flash memory is erased. the erase verify p-flash section command de?es the starting point of the code to be veri?d and the number of phrases. table 29-33. erase verify block command fccob requirements ccobix[2:0] fccob parameters 000 0x02 flash block selection code [1:0] . see table 29-34 table 29-34. flash block selection code description selection code[1:0] flash block to be veri?d 00 eeprom 01 invalid (accerr) 10 p-flash 11 p-flash table 29-35. erase verify block command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 000 at command launch set if an invalid flashblockselectioncode[1:0] is supplied fpviol none mgstat1 set if any errors have been encountered during the read or if blank check failed. mgstat0 set if any non-correctable errors have been encountered during the read or if blank check failed.
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 1070 freescale semiconductor upon clearing ccif to launch the erase verify p-flash section command, the memory controller will verify the selected section of flash memory is erased. the ccif ?g will set after the erase verify p-flash section operation has completed. if the section is not erased, it means blank check failed, both mgstat bits will be set. 29.4.6.4 read once command the read once command provides read access to a reserved 64 byte ?ld (8 phrases) located in the nonvolatile information register of p-flash. the read once ?ld is programmed using the program once command described in section 29.4.6.6 . the read once command must not be executed from the flash block containing the program once reserved ?ld to avoid code runaway. table 29-36. erase verify p-flash section command fccob requirements ccobix[2:0] fccob parameters 000 0x03 global address [17:16] of a p-flash block 001 global address [15:0] of the ?st phrase to be veri?d 010 number of phrases to be veri?d table 29-37. erase verify p-flash section command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 010 at command launch set if command not available in current mode (see table 29-27 ) set if an invalid global address [17:0] is supplied (see table 29-3 ) set if a misaligned phrase address is supplied (global address [2:0] != 000) set if the requested section crosses a the p-flash address boundary fpviol none mgstat1 set if any errors have been encountered during the read or if blank check failed. mgstat0 set if any non-correctable errors have been encountered during the read or if blank check failed. table 29-38. read once command fccob requirements ccobix[2:0] fccob parameters 000 0x04 not required 001 read once phrase index (0x0000 - 0x0007) 010 read once word 0 value 011 read once word 1 value 100 read once word 2 value 101 read once word 3 value
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1071 upon clearing ccif to launch the read once command, a read once phrase is fetched and stored in the fccob indexed register. the ccif ?g will set after the read once operation has completed. valid phrase index values for the read once command range from 0x0000 to 0x0007. during execution of the read once command, any attempt to read addresses within p-flash block will return invalid data. 8 29.4.6.5 program p-flash command the program p-flash operation will program a previously erased phrase in the p-flash memory using an embedded algorithm. caution a p-flash phrase must be in the erased state before being programmed. cumulative programming of bits within a flash phrase is not allowed. upon clearing ccif to launch the program p-flash command, the memory controller will program the data words to the supplied global address and will then proceed to verify the data words read back as expected. the ccif ?g will set after the program p-flash operation has completed. table 29-39. read once command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 29-27 ) set if an invalid phrase index is supplied fpviol none mgstat1 set if any errors have been encountered during the read mgstat0 set if any non-correctable errors have been encountered during the read table 29-40. program p-flash command fccob requirements ccobix[2:0] fccob parameters 000 0x06 global address [17:16] to identify p-flash block 001 global address [15:0] of phrase location to be programmed 1 1 global address [2:0] must be 000 010 word 0 program value 011 word 1 program value 100 word 2 program value 101 word 3 program value
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 1072 freescale semiconductor 29.4.6.6 program once command the program once command restricts programming to a reserved 64 byte ?ld (8 phrases) in the nonvolatile information register located in p-flash. the program once reserved ?ld can be read using the read once command as described in section 29.4.6.4 . the program once command must only be issued once since the nonvolatile information register in p-flash cannot be erased. the program once command must not be executed from the flash block containing the program once reserved ?ld to avoid code runaway. upon clearing ccif to launch the program once command, the memory controller ?st veri?s that the selected phrase is erased. if erased, then the selected phrase will be programmed and then veri?d with read back. the ccif ?g will remain clear, setting only after the program once operation has completed. the reserved nonvolatile information register accessed by the program once command cannot be erased and any attempt to program one of these phrases a second time will not be allowed. valid phrase index values for the program once command range from 0x0000 to 0x0007. during execution of the program once command, any attempt to read addresses within p-flash will return invalid data. table 29-41. program p-flash command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 101 at command launch set if command not available in current mode (see table 29-27 ) set if an invalid global address [17:0] is supplied (see table 29-3 ) set if a misaligned phrase address is supplied (global address [2:0] != 000) fpviol set if the global address [17:0] points to a protected area mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation table 29-42. program once command fccob requirements ccobix[2:0] fccob parameters 000 0x07 not required 001 program once phrase index (0x0000 - 0x0007) 010 program once word 0 value 011 program once word 1 value 100 program once word 2 value 101 program once word 3 value
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1073 29.4.6.7 erase all blocks command the erase all blocks operation will erase the entire p-flash and eeprom memory space. upon clearing ccif to launch the erase all blocks command, the memory controller will erase the entire flash memory space and verify that it is erased. if the memory controller veri?s that the entire flash memory space was properly erased, security will be released. during the execution of this command (ccif=0) the user must not write to any flash module register. the ccif ?g will set after the erase all blocks operation has completed. 29.4.6.8 erase flash block command the erase flash block operation will erase all addresses in a p-flash or eeprom block. table 29-43. program once command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 101 at command launch set if command not available in current mode (see table 29-27 ) set if an invalid phrase index is supplied set if the requested phrase has already been programmed 1 1 if a program once phrase is initially programmed to 0xffff_ffff_ffff_ffff, the program once command will be allowed to execute again on that same phrase. fpviol none mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation table 29-44. erase all blocks command fccob requirements ccobix[2:0] fccob parameters 000 0x08 not required table 29-45. erase all blocks command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 000 at command launch set if command not available in current mode (see table 29-27 ) fpviol set if any area of the p-flash or eeprom memory is protected mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 1074 freescale semiconductor upon clearing ccif to launch the erase flash block command, the memory controller will erase the selected flash block and verify that it is erased. the ccif ?g will set after the erase flash block operation has completed. 29.4.6.9 erase p-flash sector command the erase p-flash sector operation will erase all addresses in a p-flash sector. upon clearing ccif to launch the erase p-flash sector command, the memory controller will erase the selected flash sector and then verify that it is erased. the ccif ?g will be set after the erase p-flash sector operation has completed. table 29-46. erase flash block command fccob requirements ccobix[2:0] fccob parameters 000 0x09 global address [17:16] to identify flash block 001 global address [15:0] in flash block to be erased table 29-47. erase flash block command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 29-27 ) set if an invalid global address [17:16] is supplied set if the supplied p-flash address is not phrase-aligned or if the eeprom address is not word-aligned fpviol set if an area of the selected flash block is protected mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation table 29-48. erase p-flash sector command fccob requirements ccobix[2:0] fccob parameters 000 0x0a global address [17:16] to identify p-flash block to be erased 001 global address [15:0] anywhere within the sector to be erased. refer to section 29.1.2.1 for the p-flash sector size.
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1075 29.4.6.10 unsecure flash command the unsecure flash command will erase the entire p-flash and eeprom memory space and, if the erase is successful, will release security. upon clearing ccif to launch the unsecure flash command, the memory controller will erase the entire p-flash and eeprom memory space and verify that it is erased. if the memory controller veri?s that the entire flash memory space was properly erased, security will be released. if the erase verify is not successful, the unsecure flash operation sets mgstat1 and terminates without changing the security state. during the execution of this command (ccif=0) the user must not write to any flash module register. the ccif ?g is set after the unsecure flash operation has completed. 29.4.6.11 verify backdoor access key command the verify backdoor access key command will only execute if it is enabled by the keyen bits in the fsec register (see table 29-10 ). the verify backdoor access key command releases security if user-supplied keys match those stored in the flash security bytes of the flash con?uration ?ld (see table 29-49. erase p-flash sector command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 29-27 ) set if an invalid global address [17:16] is supplied (see table 29-3 ) set if a misaligned phrase address is supplied (global address [2:0] != 000) fpviol set if the selected p-flash sector is protected mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation table 29-50. unsecure flash command fccob requirements ccobix[2:0] fccob parameters 000 0x0b not required table 29-51. unsecure flash command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 000 at command launch set if command not available in current mode (see table 29-27 ) fpviol set if any area of the p-flash or eeprom memory is protected mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 1076 freescale semiconductor table 29-4 ). the verify backdoor access key command must not be executed from the flash block containing the backdoor comparison key to avoid code runaway. upon clearing ccif to launch the verify backdoor access key command, the memory controller will check the fsec keyen bits to verify that this command is enabled. if not enabled, the memory controller sets the accerr bit in the fstat register and terminates. if the command is enabled, the memory controller compares the key provided in fccob to the backdoor comparison key in the flash con?uration ?ld with key 0 compared to 0x3_ff00, etc. if the backdoor keys match, security will be released. if the backdoor keys do not match, security is not released and all future attempts to execute the verify backdoor access key command are aborted (set accerr) until a reset occurs. the ccif flag is set after the verify backdoor access key operation has completed. 29.4.6.12 set user margin level command the set user margin level command causes the memory controller to set the margin level for future read operations of the p-flash or eeprom block. table 29-52. verify backdoor access key command fccob requirements ccobix[2:0] fccob parameters 000 0x0c not required 001 key 0 010 key 1 011 key 2 100 key 3 table 29-53. verify backdoor access key command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 100 at command launch set if an incorrect backdoor key is supplied set if backdoor key access has not been enabled (keyen[1:0] != 10, see section 29.3.2.2 ) set if the backdoor key has mismatched since the last reset fpviol none mgstat1 none mgstat0 none table 29-54. set user margin level command fccob requirements ccobix[2:0] fccob parameters 000 0x0d flash block selection code [1:0] . see table 29-34 001 margin level setting.
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1077 upon clearing ccif to launch the set user margin level command, the memory controller will set the user margin level for the targeted block and then set the ccif ?g. note when the eeprom block is targeted, the eeprom user margin levels are applied only to the eeprom reads. however, when the p-flash block is targeted, the p-flash user margin levels are applied to both p-flash and eeprom reads. it is not possible to apply user margin levels to the p-flash block only. valid margin level settings for the set user margin level command are de?ed in table 29-55 . note user margin levels can be used to check that flash memory contents have adequate margin for normal level read operations. if unexpected results are encountered when checking flash memory contents at user margin levels, a potential loss of information has been detected. table 29-55. valid set user margin level settings ccob (ccobix=001) level description 0x0000 return to normal level 0x0001 user margin-1 level 1 1 read margin to the erased state 0x0002 user margin-0 level 2 2 read margin to the programmed state table 29-56. set user margin level command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 29-27 ) set if an invalid flashblockselectioncode[1:0] is supplied (see table 29-34 ) set if an invalid margin level setting is supplied fpviol none mgstat1 none mgstat0 none
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 1078 freescale semiconductor 29.4.6.13 set field margin level command the set field margin level command, valid in special modes only, causes the memory controller to set the margin level speci?d for future read operations of the p-flash or eeprom block. upon clearing ccif to launch the set field margin level command, the memory controller will set the ?ld margin level for the targeted block and then set the ccif ?g. note when the eeprom block is targeted, the eeprom ?ld margin levels are applied only to the eeprom reads. however, when the p-flash block is targeted, the p-flash ?ld margin levels are applied to both p-flash and eeprom reads. it is not possible to apply ?ld margin levels to the p-flash block only. valid margin level settings for the set field margin level command are de?ed in table 29-58 . table 29-57. set field margin level command fccob requirements ccobix[2:0] fccob parameters 000 0x0e flash block selection code [1:0] . see table 29-34 001 margin level setting. table 29-58. valid set field margin level settings ccob (ccobix=001) level description 0x0000 return to normal level 0x0001 user margin-1 level 1 1 read margin to the erased state 0x0002 user margin-0 level 2 2 read margin to the programmed state 0x0003 field margin-1 level 1 0x0004 field margin-0 level 2
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1079 caution field margin levels must only be used during verify of the initial factory programming. note field margin levels can be used to check that flash memory contents have adequate margin for data retention at the normal level setting. if unexpected results are encountered when checking flash memory contents at ?ld margin levels, the flash memory contents should be erased and reprogrammed. 29.4.6.14 erase verify eeprom section command the erase verify eeprom section command will verify that a section of code in the eeprom is erased. the erase verify eeprom section command de?es the starting point of the data to be veri?d and the number of words. upon clearing ccif to launch the erase verify eeprom section command, the memory controller will verify the selected section of eeprom memory is erased. the ccif ?g will set after the erase verify eeprom section operation has completed. if the section is not erased, it means blank check failed, both mgstat bits will be set. table 29-59. set field margin level command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 29-27 ) set if an invalid flashblockselectioncode[1:0] is supplied (see table 29-34 ) set if an invalid margin level setting is supplied fpviol none mgstat1 none mgstat0 none table 29-60. erase verify eeprom section command fccob requirements ccobix[2:0] fccob parameters 000 0x10 global address [17:16] to identify the eeprom block 001 global address [15:0] of the ?st word to be veri?d 010 number of words to be veri?d
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 1080 freescale semiconductor 29.4.6.15 program eeprom command the program eeprom operation programs one to four previously erased words in the eeprom block. the program eeprom operation will con?m that the targeted location(s) were successfully programmed upon completion. caution a flash word must be in the erased state before being programmed. cumulative programming of bits within a flash word is not allowed. upon clearing ccif to launch the program eeprom command, the user-supplied words will be transferred to the memory controller and be programmed if the area is unprotected. the ccobix index value at program eeprom command launch determines how many words will be programmed in the eeprom block. the ccif ?g is set when the operation has completed. table 29-61. erase verify eeprom section command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 010 at command launch set if command not available in current mode (see table 29-27 ) set if an invalid global address [17:0] is supplied set if a misaligned word address is supplied (global address [0] != 0) set if the requested section breaches the end of the eeprom block fpviol none mgstat1 set if any errors have been encountered during the read or if blank check failed. mgstat0 set if any non-correctable errors have been encountered during the read or if blank check failed. table 29-62. program eeprom command fccob requirements ccobix[2:0] fccob parameters 000 0x11 global address [17:16] to identify the eeprom block 001 global address [15:0] of word to be programmed 010 word 0 program value 011 word 1 program value, if desired 100 word 2 program value, if desired 101 word 3 program value, if desired
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1081 29.4.6.16 erase eeprom sector command the erase eeprom sector operation will erase all addresses in a sector of the eeprom block. upon clearing ccif to launch the erase eeprom sector command, the memory controller will erase the selected flash sector and verify that it is erased. the ccif ?g will set after the erase eeprom sector operation has completed. table 29-63. program eeprom command error handling register error bit error condition fstat accerr set if ccobix[2:0] < 010 at command launch set if ccobix[2:0] > 101 at command launch set if command not available in current mode (see table 29-27 ) set if an invalid global address [17:0] is supplied set if a misaligned word address is supplied (global address [0] != 0) set if the requested group of words breaches the end of the eeprom block fpviol set if the selected area of the eeprom memory is protected mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation table 29-64. erase eeprom sector command fccob requirements ccobix[2:0] fccob parameters 000 0x12 global address [17:16] to identify eeprom block 001 global address [15:0] anywhere within the sector to be erased. see section 29.1.2.2 for eeprom sector size. table 29-65. erase eeprom sector command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 29-27 ) set if an invalid global address [17:0] is supplied (see table 29-3 ) set if a misaligned word address is supplied (global address [0] != 0) fpviol set if the selected area of the eeprom memory is protected mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 1082 freescale semiconductor 29.4.7 interrupts the flash module can generate an interrupt when a flash command operation has completed or when a flash command operation has detected an ecc fault. note vector addresses and their relative interrupt priority are determined at the mcu level. 29.4.7.1 description of flash interrupt operation the flash module uses the ccif ?g in combination with the ccie interrupt enable bit to generate the flash command interrupt request. the flash module uses the dfdif and sfdif ?gs in combination with the dfdie and sfdie interrupt enable bits to generate the flash error interrupt request. for a detailed description of the register bits involved, refer to section 29.3.2.5, ?lash configuration register (fcnfg) ? section 29.3.2.6, ?lash error configuration register (fercnfg) ? section 29.3.2.7, ?lash status register (fstat) ? and section 29.3.2.8, ?lash error status register (ferstat) ? the logic used for generating the flash module interrupts is shown in figure 29-27 . figure 29-27. flash module interrupts implementation table 29-66. flash interrupt sources interrupt source interrupt flag local enable global (ccr) mask flash command complete ccif (fstat register) ccie (fcnfg register) i bit ecc double bit fault on flash read dfdif (ferstat register) dfdie (fercnfg register) i bit ecc single bit fault on flash read sfdif (ferstat register) sfdie (fercnfg register) i bit flash error interrupt request ccif ccie dfdif dfdie sfdif sfdie flash command interrupt request
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1083 29.4.8 wait mode the flash module is not affected if the mcu enters wait mode. the flash module can recover the mcu from wait via the ccif interrupt (see section 29.4.7, ?nterrupts ). 29.4.9 stop mode if a flash command is active (ccif = 0) when the mcu requests stop mode, the current flash operation will be completed before the mcu is allowed to enter stop mode. 29.5 security the flash module provides security information to the mcu. the flash security state is de?ed by the sec bits of the fsec register (see table 29-11 ). during reset, the flash module initializes the fsec register using data read from the security byte of the flash con?uration ?ld at global address 0x3_ff0f. the security state out of reset can be permanently changed by programming the security byte assuming that the mcu is starting from a mode where the necessary p-flash erase and program commands are available and that the upper region of the p-flash is unprotected. if the flash security byte is successfully programmed, its new value will take affect after the next mcu reset. the following subsections describe these security-related subjects: unsecuring the mcu using backdoor key access unsecuring the mcu in special single chip mode using bdm mode and security effects on flash command availability 29.5.1 unsecuring the mcu using backdoor key access the mcu may be unsecured by using the backdoor key access feature which requires knowledge of the contents of the backdoor keys (four 16-bit words programmed at addresses 0x3_ff00-0x3_ff07). if the keyen[1:0] bits are in the enabled state (see section 29.3.2.2 ), the verify backdoor access key command (see section 29.4.6.11 ) allows the user to present four prospective keys for comparison to the keys stored in the flash memory via the memory controller. if the keys presented in the verify backdoor access key command match the backdoor keys stored in the flash memory, the sec bits in the fsec register (see table 29-11 ) will be changed to unsecure the mcu. key values of 0x0000 and 0xffff are not permitted as backdoor keys. while the verify backdoor access key command is active, p-flash memory and eeprom memory will not be available for read access and will return invalid data.
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 1084 freescale semiconductor the user code stored in the p-flash memory must have a method of receiving the backdoor keys from an external stimulus. this external stimulus would typically be through one of the on-chip serial ports. if the keyen[1:0] bits are in the enabled state (see section 29.3.2.2 ), the mcu can be unsecured by the backdoor key access sequence described below: 1. follow the command sequence for the verify backdoor access key command as explained in section 29.4.6.11 2. if the verify backdoor access key command is successful, the mcu is unsecured and the sec[1:0] bits in the fsec register are forced to the unsecure state of 10 the verify backdoor access key command is monitored by the memory controller and an illegal key will prohibit future use of the verify backdoor access key command. a reset of the mcu is the only method to re-enable the verify backdoor access key command. the security as de?ed in the flash security byte (0x3_ff0f) is not changed by using the verify backdoor access key command sequence. the backdoor keys stored in addresses 0x3_ff00-0x3_ff07 are unaffected by the verify backdoor access key command sequence. the verify backdoor access key command sequence has no effect on the program and erase protections de?ed in the flash protection register, fprot. after the backdoor keys have been correctly matched, the mcu will be unsecured. after the mcu is unsecured, the sector containing the flash security byte can be erased and the flash security byte can be reprogrammed to the unsecure state, if desired. in the unsecure state, the user has full control of the contents of the backdoor keys by programming addresses 0x3_ff00-0x3_ff07 in the flash con?uration ?ld. 29.5.2 unsecuring the mcu in special single chip mode using bdm a secured mcu can be unsecured in special single chip mode by using the following method to erase the p-flash and eeprom memory: 1. reset the mcu into special single chip mode 2. delay while the bdm executes the erase verify all blocks command write sequence to check if the p-flash and eeprom memories are erased 3. send bdm commands to disable protection in the p-flash and eeprom memory 4. execute the erase all blocks command write sequence to erase the p-flash and eeprom memory. alternatively the unsecure flash command can be executed, if so the steps 5 and 6 below are skeeped. 5. after the ccif ?g sets to indicate that the erase all blocks operation has completed, reset the mcu into special single chip mode 6. delay while the bdm executes the erase verify all blocks command write sequence to verify that the p-flash and eeprom memory are erased if the p-flash and eeprom memory are veri?d as erased, the mcu will be unsecured. all bdm commands will now be enabled and the flash security byte may be programmed to the unsecure state by continuing with the following steps: 7. send bdm commands to execute the program p-flash command write sequence to program the flash security byte to the unsecured state
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1085 8. reset the mcu 29.5.3 mode and security effects on flash command availability the availability of flash module commands depends on the mcu operating mode and security state as shown in table 29-27 . 29.6 initialization on each system reset the ?sh module executes an initialization sequence which establishes initial values for the flash block con?uration parameters, the fprot and dfprot protection registers, and the fopt and fsec registers. the initialization routine reverts to built-in default values that leave the module in a fully protected and secured state if errors are encountered during execution of the reset sequence. if a double bit fault is detected during the reset sequence, both mgstat bits in the fstat register will be set. ccif is cleared throughout the initialization sequence. the flash module holds off all cpu access for a portion of the initialization sequence. flash reads are allowed once the hold is removed. completion of the initialization sequence is marked by setting ccif high which enables user commands. if a reset occurs while any flash command is in progress, that command will be immediately aborted. the state of the word being programmed or the sector/block being erased is not guaranteed.
128 kbyte flash module (s12ftmrg128k1v1) mc9s12g family reference manual, rev.1.23 1086 freescale semiconductor
mc9s12g family reference manual, rev.1.23 freescale semiconductor 1087 chapter 30 192 kbyte flash module (s12ftmrg192k2v1) 30.1 introduction the ftmrg192k2 module implements the following: 192kbytes of p-flash (program flash) memory 4kbytes of eeprom memory the flash memory is ideal for single-supply applications allowing for ?ld reprogramming without requiring external high voltage sources for program or erase operations. the flash module includes a memory controller that executes commands to modify flash memory contents. the user interface to the memory controller consists of the indexed flash common command object (fccob) register which is written to with the command, global address, data, and any required command parameters. the memory controller must complete the execution of a command before the fccob register can be written to with a new command. caution a flash word or phrase must be in the erased state before being programmed. cumulative programming of bits within a flash word or phrase is not allowed. table 30-1. revision history revision number revision date sections affected description of changes v01.06 23 jun 2010 30.4.6.2/30-112 1 30.4.6.12/30-11 28 30.4.6.13/30-11 29 updated description of the commands rd1blk, mloadu and mloadf v01.07 20 aug 2010 30.4.6.2/30-112 1 30.4.6.12/30-11 28 30.4.6.13/30-11 29 updated description of the commands rd1blk, mloadu and mloadf rev.1.23 31 jan 2011 30.3.2.9/30-110 4 updated description of protection on section 30.3.2.9
mc9s12g family reference manual, rev.1.23 freescale semiconductor 1088 the flash memory may be read as bytes and aligned words. read access time is one bus cycle for bytes and aligned words. for misaligned words access, the cpu has to perform twice the byte read access command. for flash memory, an erased bit reads 1 and a programmed bit reads 0. it is possible to read from p-flash memory while some commands are executing on eeprom memory. it is not possible to read from eeprom memory while a command is executing on p-flash memory. simultaneous p-flash and eeprom operations are discussed in section 30.4.5 . both p-flash and eeprom memories are implemented with error correction codes (ecc) that can resolve single bit faults and detect double bit faults. for p-flash memory, the ecc implementation requires that programming be done on an aligned 8 byte basis (a flash phrase). since p-flash memory is always read by half-phrase, only one single bit fault in an aligned 4 byte half-phrase containing the byte or word accessed will be corrected. 30.1.1 glossary command write sequence ?an mcu instruction sequence to execute built-in algorithms (including program and erase) on the flash memory. eeprom memory ?the eeprom memory constitutes the nonvolatile memory store for data. eeprom sector ?the eeprom sector is the smallest portion of the eeprom memory that can be erased. the eeprom sector consists of 4 bytes. nvm command mode an nvm mode using the cpu to setup the fccob register to pass parameters required for flash command execution. phrase ?an aligned group of four 16-bit words within the p-flash memory. each phrase includes two sets of aligned double words with each set including 7 ecc bits for single bit fault correction and double bit fault detection within each double word. p-flash memory the p-flash memory constitutes the main nonvolatile memory store for applications. p-flash sector ?the p-flash sector is the smallest portion of the p-flash memory that can be erased. each p-flash sector contains 512 bytes. program ifr ?nonvolatile information register located in the p-flash block that contains the version id, and the program once ?ld. 30.1.2 features 30.1.2.1 p-flash features 192 kbytes of p-flash memory divided into 384 sectors of 512 bytes
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1089 single bit fault correction and double bit fault detection within a 32-bit double word during read operations automated program and erase algorithm with verify and generation of ecc parity bits fast sector erase and phrase program operation ability to read the p-flash memory while programming a word in the eeprom memory flexible protection scheme to prevent accidental program or erase of p-flash memory 30.1.2.2 eeprom features 4kbytes of eeprom memory composed of one 4 kbyte flash block divided into 1024 sectors of 4 bytes single bit fault correction and double bit fault detection within a word during read operations automated program and erase algorithm with verify and generation of ecc parity bits fast sector erase and word program operation protection scheme to prevent accidental program or erase of eeprom memory ability to program up to four words in a burst sequence 30.1.2.3 other flash module features no external high-voltage power supply required for flash memory program and erase operations interrupt generation on flash command completion and flash error detection security mechanism to prevent unauthorized access to the flash memory 30.1.3 block diagram the block diagram of the flash module is shown in figure 30-1 .
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 1090 freescale semiconductor figure 30-1. ftmrg192k2 block diagram 30.2 external signal description the flash module contains no signals that connect off-chip. bus clock divider clock command interrupt request fclk protection security registers flash interface 16bit internal bus sector 0 sector 1 sector 383 48kx39 p-flash error interrupt request cpu sector 0 sector 1 sector 1023 2kx22 eeprom memory controller
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1091 30.3 memory map and registers this section describes the memory map and registers for the flash module. read data from unimplemented memory space in the flash module is unde?ed. write access to unimplemented or reserved memory space in the flash module will be ignored by the flash module. caution writing to the flash registers while a flash command is executing (that is indicated when the value of ?g ccif reads as ?? is not allowed. if such action is attempted the write operation will not change the register value. writing to the flash registers is allowed when the flash is not busy executing commands (ccif = 1) and during initialization right after reset, despite the value of ?g ccif in that case (refer to section 30.6 for a complete description of the reset sequence). . 30.3.1 module memory map the s12 architecture places the p-flash memory between global addresses 0x1_0000 and 0x3_ffff as shown in table 30-3 .the p-flash memory map is shown in figure 30-2 . table 30-2. ftmrg memory map global address (in bytes) size (bytes) description 0x0_0000 - 0x0_03ff 1,024 register space 0x0_0400 ?0x0_13ff 4,096 eeprom memory 0x0_4000 ?0x0_7fff 16,284 nvmres 1 =1 : nvm resource area (see figure 30-3 ) 1 see nvmres description in section 30.4.3 0x0_4000 ?0x0_ffff 49,152 ftmrg reserved area 0x1_0000 ?0x3_ffff 196,608 p-flash memory
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 1092 freescale semiconductor the fprot register, described in section 30.3.2.9 , can be set to protect regions in the flash memory from accidental program or erase. the flash memory addresses covered by these protectable regions are shown in the p-flash memory map. the higher address region is mainly targeted to hold the boot loader code since it covers the vector space. default protection settings as well as security information that allows the mcu to restrict access to the flash module are stored in the flash con?uration ?ld as described in table 30-4 . table 30-3. p-flash memory addressing global address size (bytes) description 0x1_0000 ?0x3_ffff 192 k p-flash block contains flash con?uration field (see table 30-4 ). table 30-4. flash con?uration field global address size (bytes) description 0x3_ff00-0x3_ff07 8 backdoor comparison key refer to section 30.4.6.11, ?erify backdoor access key command , and section 30.5.1, ?nsecuring the mcu using backdoor key access 0x3_ff08-0x3_ff0b 1 1 0x3ff08-0x3_ff0f form a flash phrase and must be programmed in a single command write sequence. each byte in the 0x3_ff08 - 0x3_ff0b reserved ?ld should be programmed to 0xff. 4 reserved 0x3_ff0c 1 1 p-flash protection byte . refer to section 30.3.2.9, ?-flash protection register (fprot) 0x3_ff0d 1 1 eeprom protection byte . refer to section 30.3.2.10, ?eprom protection register (eeprot) 0x3_ff0e 1 1 flash nonvolatile byte refer to section 30.3.2.16, ?lash option register (fopt) 0x3_ff0f 1 1 flash security byte refer to section 30.3.2.2, ?lash security register (fsec)
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1093 figure 30-2. p-flash memory map table 30-5. program ifr fields global address size (bytes) field description 0x0_4000 ?0x0_4007 8 reserved 0x0_4008 ?0x0_40b5 174 reserved 0x0_40b6 ?0x0_40b7 2 version id 1 flash con?uration field 0x3_c000 flash protected/unprotected lower region 1, 2, 4, 8 kbytes 0x3_8000 0x3_9000 0x3_8400 0x3_8800 0x3_a000 p-flash end = 0x3_ffff 0x3_f800 0x3_f000 0x3_e000 flash protected/unprotected higher region 2, 4, 8, 16 kbytes flash protected/unprotected region 8 kbytes (up to 29 kbytes) 16 bytes (0x3_ff00 - 0x3_ff0f) flash protected/unprotected region 160 kbytes p-flash start = 0x1_0000 protection protection protection movable end fixed end fixed end
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 1094 freescale semiconductor figure 30-3. memory controller resource memory map (nvmres=1) 0x0_40b8 ?0x0_40bf 8 reserved 0x0_40c0 ?0x0_40ff 64 program once field refer to section 30.4.6.6, ?rogram once command 1 used to track ?mware patch versions, see section 30.4.2 table 30-6. memory controller resource fields (nvmres 1 =1) 1 nvmres - see section 30.4.3 for nvmres (nvm resource) detail. global address size (bytes) description 0x0_4000 ?0x040ff 256 p-flash ifr (see table 30-5 ) 0x0_4100 ?0x0_41ff 256 reserved. 0x0_4200 ?0x0_57ff reserved 0x0_5800 ?0x0_5aff 768 reserved 0x0_5b00 ?0x0_5fff 1,280 reserved 0x0_6000 ?0x0_67ff 2,048 reserved 0x0_6800 ?0x0_7fff 6,144 reserved table 30-5. program ifr fields global address size (bytes) field description p-flash ifr 128 bytes (nvmres=1) 0x0_4000 reserved 6144 bytes reserved 3328 bytes 0x0_6800 0x0_7fff 0x0_4100 reserved 5632 bytes reserved 768 bytes 0x0_4200 reserved 128 bytes 0x0_5800 0x0_5aff
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1095 30.3.2 register descriptions the flash module contains a set of 20 control and status registers located between flash module base + 0x0000 and 0x0013. in the case of the writable registers, the write accesses are forbidden during fash command execution (for more detail, see caution note in section 30.3 ). a summary of the flash module registers is given in figure 30-4 with detailed descriptions in the following subsections. address & name 76543210 0x0000 fclkdiv r fdivld fdivlck fdiv5 fdiv4 fdiv3 fdiv2 fdiv1 fdiv0 w 0x0001 fsec r keyen1 keyen0 rnv5 rnv4 rnv3 rnv2 sec1 sec0 w 0x0002 fccobix r0 0 0 0 0 ccobix2 ccobix1 ccobix0 w 0x0003 frsv0 r00000000 w 0x0004 fcnfg r ccie 00 ignsf 00 fdfd fsfd w 0x0005 fercnfg r0 0 0 0 0 0 dfdie sfdie w 0x0006 fstat r ccif 0 accerr fpviol mgbusy rsvd mgstat1 mgstat0 w 0x0007 ferstat r0 0 0 0 0 0 dfdif sfdif w 0x0008 fprot r fpopen rnv6 fphdis fphs1 fphs0 fpldis fpls1 fpls0 w 0x0009 eeprot r dpopen dps6 dps5 dps4 dps3 dps2 dps1 dps0 w figure 30-4. ftmrg192k2 register summary
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 1096 freescale semiconductor 30.3.2.1 flash clock divider register (fclkdiv) the fclkdiv register is used to control timed events in program and erase algorithms. 0x000a fccobhi r ccob15 ccob14 ccob13 ccob12 ccob11 ccob10 ccob9 ccob8 w 0x000b fccoblo r ccob7 ccob6 ccob5 ccob4 ccob3 ccob2 ccob1 ccob0 w 0x000c frsv1 r00000000 w 0x000d frsv2 r00000000 w 0x000e frsv3 r00000000 w 0x000f frsv4 r00000000 w 0x0010 fopt r nv7 nv6 nv5 nv4 nv3 nv2 nv1 nv0 w 0x0011 frsv5 r00000000 w 0x0012 frsv6 r00000000 w 0x0013 frsv7 r00000000 w = unimplemented or reserved address & name 76543210 figure 30-4. ftmrg192k2 register summary (continued)
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1097 all bits in the fclkdiv register are readable, bit 7 is not writable, bit 6 is write-once-hi and controls the writability of the fdiv ?ld in normal mode. in special mode, bits 6-0 are writable any number of times but bit 7 remains unwritable. caution the fclkdiv register should never be written while a flash command is executing (ccif=0). offset module base + 0x0000 76543210 r fdivld fdivlck fdiv[5:0] w reset 00000000 = unimplemented or reserved figure 30-5. flash clock divider register (fclkdiv) table 30-7. fclkdiv field descriptions field description 7 fdivld clock divider loaded 0 fclkdiv register has not been written since the last reset 1 fclkdiv register has been written since the last reset 6 fdivlck clock divider locked 0 fdiv ?ld is open for writing 1 fdiv value is locked and cannot be changed. once the lock bit is set high, only reset can clear this bit and restore writability to the fdiv ?ld in normal mode. 5? fdiv[5:0] clock divider bits fdiv[5:0] must be set to effectively divide busclk down to 1 mhz to control timed events during flash program and erase algorithms. table 30-8 shows recommended values for fdiv[5:0] based on the busclk frequency. please refer to section 30.4.4, ?lash command operations , for more information.
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 1098 freescale semiconductor 30.3.2.2 flash security register (fsec) the fsec register holds all bits associated with the security of the mcu and flash module. all bits in the fsec register are readable but not writable. during the reset sequence, the fsec register is loaded with the contents of the flash security byte in the flash con?uration ?ld at global address 0x3_ff0f located in p-flash memory (see table 30-4 ) as table 30-8. fdiv values for various busclk frequencies busclk frequency (mhz) fdiv[5:0] busclk frequency (mhz) fdiv[5:0] min 1 1 busclk is greater than this value. max 2 2 busclk is less than or equal to this value. min 1 max 2 1.0 1.6 0x00 16.6 17.6 0x10 1.6 2.6 0x01 17.6 18.6 0x11 2.6 3.6 0x02 18.6 19.6 0x12 3.6 4.6 0x03 19.6 20.6 0x13 4.6 5.6 0x04 20.6 21.6 0x14 5.6 6.6 0x05 21.6 22.6 0x15 6.6 7.6 0x06 22.6 23.6 0x16 7.6 8.6 0x07 23.6 24.6 0x17 8.6 9.6 0x08 24.6 25.6 0x18 9.6 10.6 0x09 10.6 11.6 0x0a 11.6 12.6 0x0b 12.6 13.6 0x0c 13.6 14.6 0x0d 14.6 15.6 0x0e 15.6 16.6 0x0f offset module base + 0x0001 76543210 r keyen[1:0] rnv[5:2] sec[1:0] w reset f 1 1 loaded from ifr flash con?uration ?ld, during reset sequence. f 1 f 1 f 1 f 1 f 1 f 1 f 1 = unimplemented or reserved figure 30-6. flash security register (fsec)
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1099 indicated by reset condition f in figure 30-6 . if a double bit fault is detected while reading the p-flash phrase containing the flash security byte during the reset sequence, all bits in the fsec register will be set to leave the flash module in a secured state with backdoor key access disabled. the security function in the flash module is described in section 30.5 . 30.3.2.3 flash ccob index register (fccobix) the fccobix register is used to index the fccob register for flash memory operations. table 30-9. fsec field descriptions field description 7? keyen[1:0] backdoor key security enable bits the keyen[1:0] bits de?e the enabling of backdoor key access to the flash module as shown in table 30-10 . 5? rnv[5:2] reserved nonvolatile bits ?the rnv bits should remain in the erased state for future enhancements. 1? sec[1:0] flash security bits ?the sec[1:0] bits de?e the security state of the mcu as shown in table 30-11 . if the flash module is unsecured using backdoor key access, the sec bits are forced to 10. table 30-10. flash keyen states keyen[1:0] status of backdoor key access 00 disabled 01 disabled 1 1 preferred keyen state to disable backdoor key access. 10 enabled 11 disabled table 30-11. flash security states sec[1:0] status of security 00 secured 01 secured 1 1 preferred sec state to set mcu to secured state. 10 unsecured 11 secured offset module base + 0x0002 76543210 r00000 ccobix[2:0] w reset 00000000 = unimplemented or reserved figure 30-7. fccob index register (fccobix)
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 1100 freescale semiconductor ccobix bits are readable and writable while remaining bits read 0 and are not writable. 30.3.2.4 flash reserved0 register (frsv0) this flash register is reserved for factory testing. all bits in the frsv0 register read 0 and are not writable. 30.3.2.5 flash con?uration register (fcnfg) the fcnfg register enables the flash command complete interrupt and forces ecc faults on flash array read access from the cpu. ccie, ignsf, fdfd, and fsfd bits are readable and writable while remaining bits read 0 and are not writable. table 30-12. fccobix field descriptions field description 2? ccobix[1:0] common command register index the ccobix bits are used to select which word of the fccob register array is being read or written to. see 30.3.2.11 flash common command object register (fccob), for more details. offset module base + 0x000c 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 30-8. flash reserved0 register (frsv0) offset module base + 0x0004 76543210 r ccie 00 ignsf 00 fdfd fsfd w reset 00000000 = unimplemented or reserved figure 30-9. flash con?uration register (fcnfg)
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1101 30.3.2.6 flash error con?uration register (fercnfg) the fercnfg register enables the flash error interrupts for the ferstat ?gs. all assigned bits in the fercnfg register are readable and writable. table 30-13. fcnfg field descriptions field description 7 ccie command complete interrupt enable ?the ccie bit controls interrupt generation when a flash command has completed. 0 command complete interrupt disabled 1 an interrupt will be requested whenever the ccif ?g in the fstat register is set (see section 30.3.2.7 ) 4 ignsf ignore single bit fault ?the ignsf controls single bit fault reporting in the ferstat register (see section 30.3.2.8 ). 0 all single bit faults detected during array reads are reported 1 single bit faults detected during array reads are not reported and the single bit fault interrupt will not be generated 1 fdfd force double bit fault detect the fdfd bit allows the user to simulate a double bit fault during flash array read operations and check the associated interrupt routine. the fdfd bit is cleared by writing a 0 to fdfd. 0 flash array read operations will set the dfdif ?g in the ferstat register only if a double bit fault is detected 1 any flash array read operation will force the dfdif ?g in the ferstat register to be set (see section 30.3.2.7 ) and an interrupt will be generated as long as the dfdie interrupt enable in the fercnfg register is set (see section 30.3.2.6 ) 0 fsfd force single bit fault detect the fsfd bit allows the user to simulate a single bit fault during flash array read operations and check the associated interrupt routine. the fsfd bit is cleared by writing a 0 to fsfd. 0 flash array read operations will set the sfdif ?g in the ferstat register only if a single bit fault is detected 1 flash array read operation will force the sfdif ?g in the ferstat register to be set (see section 30.3.2.7 ) and an interrupt will be generated as long as the sfdie interrupt enable in the fercnfg register is set (see section 30.3.2.6 ) offset module base + 0x0005 76543210 r000000 dfdie sfdie w reset 00000000 = unimplemented or reserved figure 30-10. flash error con?uration register (fercnfg)
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 1102 freescale semiconductor 30.3.2.7 flash status register (fstat) the fstat register reports the operational status of the flash module. ccif, accerr, and fpviol bits are readable and writable, mgbusy and mgstat bits are readable but not writable, while remaining bits read 0 and are not writable. table 30-14. fercnfg field descriptions field description 1 dfdie double bit fault detect interrupt enable the dfdie bit controls interrupt generation when a double bit fault is detected during a flash block read operation. 0 dfdif interrupt disabled 1 an interrupt will be requested whenever the dfdif ?g is set (see section 30.3.2.8 ) 0 sfdie single bit fault detect interrupt enable the sfdie bit controls interrupt generation when a single bit fault is detected during a flash block read operation. 0 sfdif interrupt disabled whenever the sfdif ?g is set (see section 30.3.2.8 ) 1 an interrupt will be requested whenever the sfdif ?g is set (see section 30.3.2.8 ) offset module base + 0x0006 76543210 r ccif 0 accerr fpviol mgbusy rsvd mgstat[1:0] w reset 1000000 1 1 reset value can deviate from the value shown if a double bit fault is detected during the reset sequence (see section 30.6 ). 0 1 = unimplemented or reserved figure 30-11. flash status register (fstat) table 30-15. fstat field descriptions field description 7 ccif command complete interrupt flag ?the ccif ?g indicates that a flash command has completed. the ccif ?g is cleared by writing a 1 to ccif to launch a command and ccif will stay low until command completion or command violation. 0 flash command in progress 1 flash command has completed 5 accerr flash access error flag ?the accerr bit indicates an illegal access has occurred to the flash memory caused by either a violation of the command write sequence (see section 30.4.4.2 ) or issuing an illegal flash command. while accerr is set, the ccif ?g cannot be cleared to launch a command. the accerr bit is cleared by writing a 1 to accerr. writing a 0 to the accerr bit has no effect on accerr. 0 no access error detected 1 access error detected 4 fpviol flash protection violation flag ?he fpviol bit indicates an attempt was made to program or erase an address in a protected area of p-flash or eeprom memory during a command write sequence. the fpviol bit is cleared by writing a 1 to fpviol. writing a 0 to the fpviol bit has no effect on fpviol. while fpviol is set, it is not possible to launch a command or start a command write sequence. 0 no protection violation detected 1 protection violation detected
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1103 30.3.2.8 flash error status register (ferstat) the ferstat register re?cts the error status of internal flash operations. all ?gs in the ferstat register are readable and only writable to clear the ?g. 3 mgbusy memory controller busy flag ?the mgbusy ?g re?cts the active state of the memory controller . 0 memory controller is idle 1 memory controller is busy executing a flash command (ccif = 0) 2 rsvd reserved bit ?this bit is reserved and always reads 0 . 1? mgstat[1:0] memory controller command completion status flag one or more mgstat ?g bits are set if an error is detected during execution of a flash command or during the flash reset sequence. see section 30.4.6, ?lash command description , and section 30.6, ?nitialization ?for details. offset module base + 0x0007 76543210 r000000 dfdif sfdif w reset 00000000 = unimplemented or reserved figure 30-12. flash error status register (ferstat) table 30-16. ferstat field descriptions field description 1 dfdif double bit fault detect interrupt flag ?the setting of the dfdif ?g indicates that a double bit fault was detected in the stored parity and data bits during a flash array read operation or that a flash array read operation returning invalid data was attempted on a flash block that was under a flash command operation. 1 the dfdif ?g is cleared by writing a 1 to dfdif. writing a 0 to dfdif has no effect on dfdif. 2 0 no double bit fault detected 1 double bit fault detected or a flash array read operation returning invalid data was attempted while command running 1 the single bit fault and double bit fault ?gs are mutually exclusive for parity errors (an ecc fault occurrence can be either single fault or double fault but never both). a simultaneous access collision (flash array read operation returning invalid data attempted while command running) is indicated when both sfdif and dfdif ?gs are high. 2 there is a one cycle delay in storing the ecc dfdif and sfdif fault ?gs in this register. at least one nop is required after a ?sh memory read before checking ferstat for the occurrence of ecc errors. 0 sfdif single bit fault detect interrupt flag ?with the ignsf bit in the fcnfg register clear, the sfdif ?g indicates that a single bit fault was detected in the stored parity and data bits during a flash array read operation or that a flash array read operation returning invalid data was attempted on a flash block that was under a flash command operation. 1 the sfdif ?g is cleared by writing a 1 to sfdif. writing a 0 to sfdif has no effect on sfdif. 0 no single bit fault detected 1 single bit fault detected and corrected or a flash array read operation returning invalid data was attempted while command running table 30-15. fstat field descriptions (continued) field description
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 1104 freescale semiconductor 30.3.2.9 p-flash protection register (fprot) the fprot register de?es which p-flash sectors are protected against program and erase operations. the (unreserved) bits of the fprot register are writable with the restriction that the size of the protected region can only be increased (see section 30.3.2.9.1, ?-flash protection restrictions , and table 30-21 ). during the reset sequence, the fprot register is loaded with the contents of the p-flash protection byte in the flash con?uration ?ld at global address 0x3_ff0c located in p-flash memory (see table 30-4 ) as indicated by reset condition ??in figure 30-13 . to change the p-flash protection that will be loaded during the reset sequence, the upper sector of the p-flash memory must be unprotected, then the p-flash protection byte must be reprogrammed. if a double bit fault is detected while reading the p-flash phrase containing the p-flash protection byte during the reset sequence, the fpopen bit will be cleared and remaining bits in the fprot register will be set to leave the p-flash memory fully protected. trying to alter data in any protected area in the p-flash memory will result in a protection violation error and the fpviol bit will be set in the fstat register. the block erase of a p-flash block is not possible if any of the p-flash sectors contained in the same p-flash block are protected. offset module base + 0x0008 76543210 r fpopen rnv6 fphdis fphs[1:0] fpldis fpls[1:0] w reset f 1 1 loaded from ifr flash con?uration ?ld, during reset sequence. f 1 f 1 f 1 f 1 f 1 f 1 f 1 = unimplemented or reserved figure 30-13. flash protection register (fprot) table 30-17. fprot field descriptions field description 7 fpopen flash protection operation enable ?the fpopen bit determines the protection function for program or erase operations as shown in table 30-18 for the p-flash block. 0 when fpopen is clear, the fphdis and fpldis bits de?e unprotected address ranges as speci?d by the corresponding fphs and fpls bits 1 when fpopen is set, the fphdis and fpldis bits enable protection for the address range speci?d by the corresponding fphs and fpls bits 6 rnv[6] reserved nonvolatile bit ?the rnv bit should remain in the erased state for future enhancements. 5 fphdis flash protection higher address range disable ?the fphdis bit determines whether there is a protected/unprotected area in a speci? region of the p-flash memory ending with global address 0x3_ffff. 0 protection/unprotection enabled 1 protection/unprotection disabled 4? fphs[1:0] flash protection higher address size the fphs bits determine the size of the protected/unprotected area in p-flash memory as shown in table 30-19 . the fphs bits can only be written to while the fphdis bit is set.
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1105 all possible p-flash protection scenarios are shown in figure 30-14 . although the protection scheme is loaded from the flash memory at global address 0x3_ff0c during the reset sequence, it can be changed by the user. the p-flash protection scheme can be used by applications requiring reprogramming in single chip mode while providing as much protection as possible if reprogramming is not required. 2 fpldis flash protection lower address range disable ?the fpldis bit determines whether there is a protected/unprotected area in a speci? region of the p-flash memory beginning with global address 0x3_8000. 0 protection/unprotection enabled 1 protection/unprotection disabled 1? fpls[1:0] flash protection lower address size the fpls bits determine the size of the protected/unprotected area in p-flash memory as shown in table 30-20 . the fpls bits can only be written to while the fpldis bit is set. table 30-18. p-flash protection function fpopen fphdis fpldis function 1 1 for range sizes, refer to table 30-19 and table 30-20 . 1 1 1 no p-flash protection 1 1 0 protected low range 1 0 1 protected high range 1 0 0 protected high and low ranges 0 1 1 full p-flash memory protected 0 1 0 unprotected low range 0 0 1 unprotected high range 0 0 0 unprotected high and low ranges table 30-19. p-flash protection higher address range fphs[1:0] global address range protected size 00 0x3_f800?x3_ffff 2 kbytes 01 0x3_f000?x3_ffff 4 kbytes 10 0x3_e000?x3_ffff 8 kbytes 11 0x3_c000?x3_ffff 16 kbytes table 30-20. p-flash protection lower address range fpls[1:0] global address range protected size 00 0x3_8000?x3_83ff 1 kbyte 01 0x3_8000?x3_87ff 2 kbytes 10 0x3_8000?x3_8fff 4 kbytes 11 0x3_8000?x3_9fff 8 kbytes table 30-17. fprot field descriptions (continued) field description
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 1106 freescale semiconductor figure 30-14. p-flash protection scenarios 7 6 5 4 fphs[1:0] fpls[1:0] 3 2 1 0 fphs[1:0] fpls[1:0] fphdis = 1 fpldis = 1 fphdis = 1 fpldis = 0 fphdis = 0 fpldis = 1 fphdis = 0 fpldis = 0 scenario scenario unprotected region protected region with size protected region protected region with size defined by fpls defined by fphs not defined by fpls, fphs 0x3_8000 0x3_ffff 0x3_8000 0x3_ffff flash start flash start fpopen = 1 fpopen = 0
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1107 30.3.2.9.1 p-flash protection restrictions the general guideline is that p-flash protection can only be added and not removed. table 30-21 speci?s all valid transitions between p-flash protection scenarios. any attempt to write an invalid scenario to the fprot register will be ignored. the contents of the fprot register re?ct the active protection scenario. see the fphs and fpls bit descriptions for additional restrictions. 30.3.2.10 eeprom protection register (eeprot) the eeprot register de?es which eeprom sectors are protected against program and erase operations. the (unreserved) bits of the eeprot register are writable with the restriction that protection can be added but not removed. writes must increase the dps value and the dpopen bit can only be written from 1 (protection disabled) to 0 (protection enabled). if the dpopen bit is set, the state of the dps bits is irrelevant. during the reset sequence, ?lds dpopen and dps of the eeprot register are loaded with the contents of the eeprom protection byte in the flash configuration field at global address 0x3_ff0d located in table 30-21. p-flash protection scenario transitions from protection scenario to protection scenario 1 1 allowed transitions marked with x, see figure 30-14 for a de?ition of the scenarios. 01234567 0 xxxx 1 xx 2 xx 3 x 4 xx 5 xxxx 6 xxxx 7 xxxxxxxx offset module base + 0x0009 76543210 r dpopen dps[6:0] w reset f 1 1 loaded from ifr flash con?uration ?ld, during reset sequence. f 1 f 1 f 1 f 1 f 1 f 1 f 1 figure 30-15. eeprom protection register (eeprot)
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 1108 freescale semiconductor p-flash memory (see table 30-4 ) as indicated by reset condition f in table 30-23 . to change the eeprom protection that will be loaded during the reset sequence, the p-flash sector containing the eeprom protection byte must be unprotected, then the eeprom protection byte must be programmed. if a double bit fault is detected while reading the p-flash phrase containing the eeprom protection byte during the reset sequence, the dpopen bit will be cleared and dps bits will be set to leave the eeprom memory fully protected. trying to alter data in any protected area in the eeprom memory will result in a protection violation error and the fpviol bit will be set in the fstat register. block erase of the eeprom memory is not possible if any of the eeprom sectors are protected. table 30-22. eeprot field descriptions field description 7 dpopen eeprom protection control 0 enables eeprom memory protection from program and erase with protected address range de?ed by dps bits 1 disables eeprom memory protection from program and erase 6? dps[6:0] eeprom protection size ?the dps[6:0] bits determine the size of the protected area in the eeprom memory, this size increase in step of 32 bytes, as shown in table 30-23 . table 30-23. eeprom protection address range dps[6:0] global address range protected size 0000000 0x0_0400 ?0x0_041f 32 bytes 0000001 0x0_0400 ?0x0_043f 64 bytes 0000010 0x0_0400 ?0x0_045f 96 bytes 0000011 0x0_0400 ?0x0_047f 128 bytes 0000100 0x0_0400 ?0x0_049f 160 bytes 0000101 0x0_0400 ?0x0_04bf 192 bytes the protection size goes on enlarging in step of 32 bytes, for each dps value increasing of one. . . . 1111111 0x0_0400 ?0x0_13ff 4,096 bytes
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1109 30.3.2.11 flash common command object register (fccob) the fccob is an array of six words addressed via the ccobix index found in the fccobix register. byte wide reads and writes are allowed to the fccob register. 30.3.2.11.1 fccob - nvm command mode nvm command mode uses the indexed fccob register to provide a command code and its relevant parameters to the memory controller. the user ?st sets up all required fccob ?lds and then initiates the commands execution by writing a 1 to the ccif bit in the fstat register (a 1 written by the user clears the ccif command completion ?g to 0). when the user clears the ccif bit in the fstat register all fccob parameter ?lds are locked and cannot be changed by the user until the command completes (as evidenced by the memory controller returning ccif to 1). some commands return information to the fccob register array. the generic format for the fccob parameter ?lds in nvm command mode is shown in table 30-24 . the return values are available for reading after the ccif ?g in the fstat register has been returned to 1 by the memory controller. writes to the unimplemented parameter ?lds (ccobix = 110 and ccobix = 111) are ignored with reads from these ?lds returning 0x0000. table 30-24 shows the generic flash command format. the high byte of the ?st word in the ccob array contains the command code, followed by the parameters for this speci? flash command. for details on the fccob settings required by each command, see the flash command descriptions in section 30.4.6 . offset module base + 0x000a 76543210 r ccob[15:8] w reset 00000000 figure 30-16. flash common command object high register (fccobhi) offset module base + 0x000b 76543210 r ccob[7:0] w reset 00000000 figure 30-17. flash common command object low register (fccoblo) table 30-24. fccob - nvm command mode (typical usage) ccobix[2:0] byte fccob parameter fields (nvm command mode) 000 hi fcmd[7:0] de?ing flash command lo 6?0, global address [17:16] 001 hi global address [15:8] lo global address [7:0]
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 1110 freescale semiconductor 30.3.2.12 flash reserved1 register (frsv1) this flash register is reserved for factory testing. all bits in the frsv1 register read 0 and are not writable. 30.3.2.13 flash reserved2 register (frsv2) this flash register is reserved for factory testing. all bits in the frsv2 register read 0 and are not writable. 30.3.2.14 flash reserved3 register (frsv3) this flash register is reserved for factory testing. 010 hi data 0 [15:8] lo data 0 [7:0] 011 hi data 1 [15:8] lo data 1 [7:0] 100 hi data 2 [15:8] lo data 2 [7:0] 101 hi data 3 [15:8] lo data 3 [7:0] offset module base + 0x000c 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 30-18. flash reserved1 register (frsv1) offset module base + 0x000d 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 30-19. flash reserved2 register (frsv2) table 30-24. fccob - nvm command mode (typical usage) ccobix[2:0] byte fccob parameter fields (nvm command mode)
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1111 all bits in the frsv3 register read 0 and are not writable. 30.3.2.15 flash reserved4 register (frsv4) this flash register is reserved for factory testing. all bits in the frsv4 register read 0 and are not writable. 30.3.2.16 flash option register (fopt) the fopt register is the flash option register. all bits in the fopt register are readable but are not writable. during the reset sequence, the fopt register is loaded from the flash nonvolatile byte in the flash con?uration ?ld at global address 0x3_ff0e located in p-flash memory (see table 30-4 ) as indicated by reset condition f in figure 30-22 . if a double bit fault is detected while reading the p-flash phrase containing the flash nonvolatile byte during the reset sequence, all bits in the fopt register will be set. offset module base + 0x000e 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 30-20. flash reserved3 register (frsv3) offset module base + 0x000f 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 30-21. flash reserved4 register (frsv4) offset module base + 0x0010 76543210 r nv[7:0] w reset f 1 1 loaded from ifr flash con?uration ?ld, during reset sequence. f 1 f 1 f 1 f 1 f 1 f 1 f 1 = unimplemented or reserved figure 30-22. flash option register (fopt)
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 1112 freescale semiconductor 30.3.2.17 flash reserved5 register (frsv5) this flash register is reserved for factory testing. all bits in the frsv5 register read 0 and are not writable. 30.3.2.18 flash reserved6 register (frsv6) this flash register is reserved for factory testing. all bits in the frsv6 register read 0 and are not writable. 30.3.2.19 flash reserved7 register (frsv7) this flash register is reserved for factory testing. table 30-25. fopt field descriptions field description 7? nv[7:0] nonvolatile bits the nv[7:0] bits are available as nonvolatile bits. refer to the device user guide for proper use of the nv bits. offset module base + 0x0011 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 30-23. flash reserved5 register (frsv5) offset module base + 0x0012 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 30-24. flash reserved6 register (frsv6)
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1113 all bits in the frsv7 register read 0 and are not writable. 30.4 functional description 30.4.1 modes of operation the ftmrg192k2 module provides the modes of operation normal and special . the operating mode is determined by module-level inputs and affects the fclkdiv, fcnfg, and eeprot registers (see table 30-27 ). 30.4.2 ifr version id word the version id word is stored in the ifr at address 0x0_40b6. the contents of the word are de?ed in table 30-26 . vernum: version number. the ?st version is number 0b_0001 with both 0b_0000 and 0b_1111 meaning ?one? offset module base + 0x0013 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 30-25. flash reserved7 register (frsv7) table 30-26. ifr version id fields [15:4] [3:0] reserved vernum
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 1114 freescale semiconductor 30.4.3 internal nvm resource (nvmres) ifr is an internal nvm resource readable by cpu , when nvmres is active. the ifr ?lds are shown in table 30-5 . the nvmres global address map is shown in table 30-6 . 30.4.4 flash command operations flash command operations are used to modify flash memory contents. the next sections describe: how to write the fclkdiv register that is used to generate a time base (fclk) derived from busclk for flash program and erase command operations the command write sequence used to set flash command parameters and launch execution valid flash commands available for execution, according to mcu functional mode and mcu security state. 30.4.4.1 writing the fclkdiv register prior to issuing any flash program or erase command after a reset, the user is required to write the fclkdiv register to divide busclk down to a target fclk of 1 mhz. table 30-8 shows recommended values for the fdiv ?ld based on busclk frequency. note programming or erasing the flash memory cannot be performed if the bus clock runs at less than 0.8 mhz. setting fdiv too high can destroy the flash memory due to overstress. setting fdiv too low can result in incomplete programming or erasure of the flash memory cells. when the fclkdiv register is written, the fdivld bit is set automatically. if the fdivld bit is 0, the fclkdiv register has not been written since the last reset. if the fclkdiv register has not been written, any flash program or erase command loaded during a command write sequence will not execute and the accerr bit in the fstat register will set. 30.4.4.2 command write sequence the memory controller will launch all valid flash commands entered using a command write sequence. before launching a command, the accerr and fpviol bits in the fstat register must be clear (see section 30.3.2.7 ) and the ccif ?g should be tested to determine the status of the current command write sequence. if ccif is 0, the previous command write sequence is still active, a new command write sequence cannot be started, and all writes to the fccob register are ignored.
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1115 30.4.4.2.1 de?e fccob contents the fccob parameter ?lds must be loaded with all required parameters for the flash command being executed. access to the fccob parameter ?lds is controlled via the ccobix bits in the fccobix register (see section 30.3.2.3 ). the contents of the fccob parameter ?lds are transferred to the memory controller when the user clears the ccif command completion ?g in the fstat register (writing 1 clears the ccif to 0). the ccif ?g will remain clear until the flash command has completed. upon completion, the memory controller will return ccif to 1 and the fccob register will be used to communicate any results. the ?w for a generic command write sequence is shown in figure 30-26 .
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 1116 freescale semiconductor figure 30-26. generic flash command write sequence flowchart write to fccobix register write: fstat register (to launch command) clear ccif 0x80 clear accerr/fpviol 0x30 write: fstat register yes no access error and protection violation read: fstat register start check fccob accerr/ fpviol set? exit write: fclkdiv register read: fclkdiv register yes no fdiv correct? no bit polling for command completion check yes ccif set? to identify speci? command parameter to load. write to fccob register to load required command parameter. yes no more parameters? availability check results from previous command note: fclkdiv must be set after each reset read: fstat register no yes ccif set? no yes ccif set? clock divider value check read: fstat register
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1117 30.4.4.3 valid flash module commands table 30-27 present the valid flash commands, as enabled by the combination of the functional mcu mode (normal singlechip ns, special singlechip ss) with the mcu security state (unsecured, secured). special singlechip mode is selected by input mmc_ss_mode_ts2 asserted. mcu secured state is selected by input mmc_secure input asserted. + 30.4.4.4 p-flash commands table 30-28 summarizes the valid p-flash commands along with the effects of the commands on the p-flash block and other resources within the flash module. table 30-27. flash commands by mode and security state fcmd command unsecured secured ns 1 1 unsecured normal single chip mode ss 2 2 unsecured special single chip mode. ns 3 3 secured normal single chip mode. ss 4 4 secured special single chip mode. 0x01 erase verify all blocks ???? 0x02 erase verify block ???? 0x03 erase verify p-flash section ??? 0x04 read once ??? 0x06 program p-flash ??? 0x07 program once ??? 0x08 erase all blocks ?? 0x09 erase flash block ??? 0x0a erase p-flash sector ??? 0x0b unsecure flash ?? 0x0c verify backdoor access key ?? 0x0d set user margin level ??? 0x0e set field margin level ? 0x10 erase verify eeprom section ??? 0x11 program eeprom ??? 0x12 erase eeprom sector ??? table 30-28. p-flash commands fcmd command function on p-flash memory 0x01 erase verify all blocks verify that all p-flash (and eeprom) blocks are erased.
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 1118 freescale semiconductor 30.4.4.5 eeprom commands table 30-29 summarizes the valid eeprom commands along with the effects of the commands on the eeprom block. 0x02 erase verify block verify that a p-flash block is erased. 0x03 erase verify p-flash section verify that a given number of words starting at the address provided are erased. 0x04 read once read a dedicated 64 byte ?ld in the nonvolatile information register in p-flash block that was previously programmed using the program once command. 0x06 program p-flash program a phrase in a p-flash block. 0x07 program once program a dedicated 64 byte ?ld in the nonvolatile information register in p-flash block that is allowed to be programmed only once. 0x08 erase all blocks erase all p-flash (and eeprom) blocks. an erase of all flash blocks is only possible when the fpldis, fphdis, and fpopen bits in the fprot register and the dpopen bit in the eeprot register are set prior to launching the command. 0x09 erase flash block erase a p-flash (or eeprom) block. an erase of the full p-flash block is only possible when fpldis, fphdis and fpopen bits in the fprot register are set prior to launching the command. 0x0a erase p-flash sector erase all bytes in a p-flash sector. 0x0b unsecure flash supports a method of releasing mcu security by erasing all p-flash (and eeprom) blocks and verifying that all p-flash (and eeprom) blocks are erased. 0x0c verify backdoor access key supports a method of releasing mcu security by verifying a set of security keys. 0x0d set user margin level speci?s a user margin read level for all p-flash blocks. 0x0e set field margin level speci?s a ?ld margin read level for all p-flash blocks (special modes only). table 30-29. eeprom commands fcmd command function on eeprom memory 0x01 erase verify all blocks verify that all eeprom (and p-flash) blocks are erased. 0x02 erase verify block verify that the eeprom block is erased. table 30-28. p-flash commands fcmd command function on p-flash memory
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1119 30.4.5 allowed simultaneous p-flash and eeprom operations only the operations marked ?k?in table 30-30 are permitted to be run simultaneously on the program flash and eeprom blocks. some operations cannot be executed simultaneously because certain hardware resources are shared by the two memories. the priority has been placed on permitting program flash reads while program and erase operations execute on the eeprom, providing read (p-flash) while write (eeprom) functionality. 0x08 erase all blocks erase all eeprom (and p-flash) blocks. an erase of all flash blocks is only possible when the fpldis, fphdis, and fpopen bits in the fprot register and the dpopen bit in the eeprot register are set prior to launching the command. 0x09 erase flash block erase a eeprom (or p-flash) block. an erase of the full eeprom block is only possible when dpopen bit in the eeprot register is set prior to launching the command. 0x0b unsecure flash supports a method of releasing mcu security by erasing all eeprom (and p-flash) blocks and verifying that all eeprom (and p-flash) blocks are erased. 0x0d set user margin level speci?s a user margin read level for the eeprom block. 0x0e set field margin level speci?s a ?ld margin read level for the eeprom block (special modes only). 0x10 erase verify eeprom section verify that a given number of words starting at the address provided are erased. 0x11 program eeprom program up to four words in the eeprom block. 0x12 erase eeprom sector erase all bytes in a sector of the eeprom block. table 30-30. allowed p-flash and eeprom simultaneous operations eeprom program flash read margin read 1 program sector erase mass erase 2 read ok ok ok margin read 1 1 a ?argin read?is any read after executing the margin setting commands ?et user margin level?or ?et field margin level?with anything but the ?ormal level speci?d. see the note on margin settings in section 30.4.6.12 and section 30.4.6.13 . program sector erase mass erase 2 2 the ?ass erase?operations are commands ?rase all blocks?and ?rase flash block ok table 30-29. eeprom commands fcmd command function on eeprom memory
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 1120 freescale semiconductor 30.4.6 flash command description this section provides details of all available flash commands launched by a command write sequence. the accerr bit in the fstat register will be set during the command write sequence if any of the following illegal steps are performed, causing the command not to be processed by the memory controller: starting any command write sequence that programs or erases flash memory before initializing the fclkdiv register writing an invalid command as part of the command write sequence for additional possible errors, refer to the error handling table provided for each command if a flash block is read during execution of an algorithm (ccif = 0) on that same block, the read operation will return invalid data if both ?gs sfdif and dfdif are set. if the sfdif or dfdif ?gs were not previously set when the invalid read operation occurred, both the sfdif and dfdif ?gs will be set. if the accerr or fpviol bits are set in the fstat register, the user must clear these bits before starting any command write sequence (see section 30.3.2.7 ). caution a flash word or phrase must be in the erased state before being programmed. cumulative programming of bits within a flash word or phrase is not allowed. 30.4.6.1 erase verify all blocks command the erase verify all blocks command will verify that all p-flash and eeprom blocks have been erased. upon clearing ccif to launch the erase verify all blocks command, the memory controller will verify that the entire flash memory space is erased. the ccif ?g will set after the erase verify all blocks operation has completed. if all blocks are not erased, it means blank check failed, both mgstat bits will be set. table 30-31. erase verify all blocks command fccob requirements ccobix[2:0] fccob parameters 000 0x01 not required table 30-32. erase verify all blocks command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 000 at command launch fpviol none mgstat1 set if any errors have been encountered during the reador if blank check failed . mgstat0 set if any non-correctable errors have been encountered during the read or if blank check failed.
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1121 30.4.6.2 erase verify block command the erase verify block command allows the user to verify that an entire p-flash or eeprom block has been erased. the fccob flashblockselectioncode[1:0]bits determine which block must be veri?d. upon clearing ccif to launch the erase verify block command, the memory controller will verify that the selected p-flash or eeprom block is erased. the ccif ?g will set after the erase verify block operation has completed.if the block is not erased, it means blank check failed, both mgstat bits will be set. 30.4.6.3 erase verify p-flash section command the erase verify p-flash section command will verify that a section of code in the p-flash memory is erased. the erase verify p-flash section command de?es the starting point of the code to be veri?d and the number of phrases. table 30-33. erase verify block command fccob requirements ccobix[2:0] fccob parameters 000 0x02 flash block selection code [1:0] . see table 30-34 table 30-34. flash block selection code description selection code[1:0] flash block to be veri?d 00 eeprom 01 p-flash 10 p-flash 11 p-flash table 30-35. erase verify block command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 000 at command launch. fpviol none. mgstat1 set if any errors have been encountered during the read or if blank check failed. mgstat0 set if any non-correctable errors have been encountered during the read 1 or if blank check failed.
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 1122 freescale semiconductor upon clearing ccif to launch the erase verify p-flash section command, the memory controller will verify the selected section of flash memory is erased. the ccif ?g will set after the erase verify p-flash section operation has completed. if the section is not erased, it means blank check failed, both mgstat bits will be set. 30.4.6.4 read once command the read once command provides read access to a reserved 64 byte ?ld (8 phrases) located in the nonvolatile information register of p-flash. the read once ?ld is programmed using the program once command described in section 30.4.6.6 . the read once command must not be executed from the flash block containing the program once reserved ?ld to avoid code runaway. table 30-36. erase verify p-flash section command fccob requirements ccobix[2:0] fccob parameters 000 0x03 global address [17:16] of a p-flash block 001 global address [15:0] of the ?st phrase to be veri?d 010 number of phrases to be veri?d table 30-37. erase verify p-flash section command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 010 at command launch set if command not available in current mode (see table 30-27 ) set if an invalid global address [17:0] is supplied see table 30-3 ) set if a misaligned phrase address is supplied (global address [2:0] != 000) set if the requested section crosses a the p-flash address boundary fpviol none mgstat1 set if any errors have been encountered during the read or if blank check failed. mgstat0 set if any non-correctable errors have been encountered during the read or if blank check failed. table 30-38. read once command fccob requirements ccobix[2:0] fccob parameters 000 0x04 not required 001 read once phrase index (0x0000 - 0x0007) 010 read once word 0 value 011 read once word 1 value 100 read once word 2 value 101 read once word 3 value
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1123 upon clearing ccif to launch the read once command, a read once phrase is fetched and stored in the fccob indexed register. the ccif ?g will set after the read once operation has completed. valid phrase index values for the read once command range from 0x0000 to 0x0007. during execution of the read once command, any attempt to read addresses within p-flash block will return invalid data. 8 30.4.6.5 program p-flash command the program p-flash operation will program a previously erased phrase in the p-flash memory using an embedded algorithm. caution a p-flash phrase must be in the erased state before being programmed. cumulative programming of bits within a flash phrase is not allowed. upon clearing ccif to launch the program p-flash command, the memory controller will program the data words to the supplied global address and will then proceed to verify the data words read back as expected. the ccif ?g will set after the program p-flash operation has completed. table 30-39. read once command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 30-27 ) set if an invalid phrase index is supplied fpviol none mgstat1 set if any errors have been encountered during the read mgstat0 set if any non-correctable errors have been encountered during the read table 30-40. program p-flash command fccob requirements ccobix[2:0] fccob parameters 000 0x06 global address [17:16] to identify p-flash block 001 global address [15:0] of phrase location to be programmed 1 1 global address [2:0] must be 000 010 word 0 program value 011 word 1 program value 100 word 2 program value 101 word 3 program value
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 1124 freescale semiconductor 30.4.6.6 program once command the program once command restricts programming to a reserved 64 byte ?ld (8 phrases) in the nonvolatile information register located in p-flash. the program once reserved ?ld can be read using the read once command as described in section 30.4.6.4 . the program once command must only be issued once since the nonvolatile information register in p-flash cannot be erased. the program once command must not be executed from the flash block containing the program once reserved ?ld to avoid code runaway. upon clearing ccif to launch the program once command, the memory controller ?st veri?s that the selected phrase is erased. if erased, then the selected phrase will be programmed and then veri?d with read back. the ccif ?g will remain clear, setting only after the program once operation has completed. the reserved nonvolatile information register accessed by the program once command cannot be erased and any attempt to program one of these phrases a second time will not be allowed. valid phrase index values for the program once command range from 0x0000 to 0x0007. during execution of the program once command, any attempt to read addresses within p-flash will return invalid data. table 30-41. program p-flash command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 101 at command launch set if command not available in current mode (see table 30-27 ) set if an invalid global address [17:0] is supplied see table 30-3 ) set if a misaligned phrase address is supplied (global address [2:0] != 000) fpviol set if the global address [17:0] points to a protected area mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation table 30-42. program once command fccob requirements ccobix[2:0] fccob parameters 000 0x07 not required 001 program once phrase index (0x0000 - 0x0007) 010 program once word 0 value 011 program once word 1 value 100 program once word 2 value 101 program once word 3 value
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1125 30.4.6.7 erase all blocks command the erase all blocks operation will erase the entire p-flash and eeprom memory space. upon clearing ccif to launch the erase all blocks command, the memory controller will erase the entire flash memory space and verify that it is erased. if the memory controller veri?s that the entire flash memory space was properly erased, security will be released. during the execution of this command (ccif=0) the user must not write to any flash module register. the ccif ?g will set after the erase all blocks operation has completed. 30.4.6.8 erase flash block command the erase flash block operation will erase all addresses in a p-flash or eeprom block. table 30-43. program once command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 101 at command launch set if command not available in current mode (see table 30-27 ) set if an invalid phrase index is supplied set if the requested phrase has already been programmed 1 1 if a program once phrase is initially programmed to 0xffff_ffff_ffff_ffff, the program once command will be allowed to execute again on that same phrase. fpviol none mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation table 30-44. erase all blocks command fccob requirements ccobix[2:0] fccob parameters 000 0x08 not required table 30-45. erase all blocks command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 000 at command launch set if command not available in current mode (see table 30-27 ) fpviol set if any area of the p-flash or eeprom memory is protected mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 1126 freescale semiconductor upon clearing ccif to launch the erase flash block command, the memory controller will erase the selected flash block and verify that it is erased. the ccif ?g will set after the erase flash block operation has completed. 30.4.6.9 erase p-flash sector command the erase p-flash sector operation will erase all addresses in a p-flash sector. upon clearing ccif to launch the erase p-flash sector command, the memory controller will erase the selected flash sector and then verify that it is erased. the ccif ?g will be set after the erase p-flash sector operation has completed. table 30-46. erase flash block command fccob requirements ccobix[2:0] fccob parameters 000 0x09 global address [17:16] to identify flash block 001 global address [15:0] in flash block to be erased table 30-47. erase flash block command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 30-27 ) set if an invalid global address [17:16] is supplied set if the supplied p-flash address is not phrase-aligned or if the eeprom address is not word-aligned fpviol set if an area of the selected flash block is protected mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation table 30-48. erase p-flash sector command fccob requirements ccobix[2:0] fccob parameters 000 0x0a global address [17:16] to identify p-flash block to be erased 001 global address [15:0] anywhere within the sector to be erased. refer to section 30.1.2.1 for the p-flash sector size.
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1127 30.4.6.10 unsecure flash command the unsecure flash command will erase the entire p-flash and eeprom memory space and, if the erase is successful, will release security. upon clearing ccif to launch the unsecure flash command, the memory controller will erase the entire p-flash and eeprom memory space and verify that it is erased. if the memory controller veri?s that the entire flash memory space was properly erased, security will be released. if the erase verify is not successful, the unsecure flash operation sets mgstat1 and terminates without changing the security state. during the execution of this command (ccif=0) the user must not write to any flash module register. the ccif ?g is set after the unsecure flash operation has completed. 30.4.6.11 verify backdoor access key command the verify backdoor access key command will only execute if it is enabled by the keyen bits in the fsec register (see table 30-10 ). the verify backdoor access key command releases security if user-supplied keys match those stored in the flash security bytes of the flash con?uration ?ld (see table 30-49. erase p-flash sector command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 30-27 ) set if an invalid global address [17:16] is supplied see table 30-3 ) set if a misaligned phrase address is supplied (global address [2:0] != 000) fpviol set if the selected p-flash sector is protected mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation table 30-50. unsecure flash command fccob requirements ccobix[2:0] fccob parameters 000 0x0b not required table 30-51. unsecure flash command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 000 at command launch set if command not available in current mode (see table 30-27 ) fpviol set if any area of the p-flash or eeprom memory is protected mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 1128 freescale semiconductor table 30-4 ). the verify backdoor access key command must not be executed from the flash block containing the backdoor comparison key to avoid code runaway. upon clearing ccif to launch the verify backdoor access key command, the memory controller will check the fsec keyen bits to verify that this command is enabled. if not enabled, the memory controller sets the accerr bit in the fstat register and terminates. if the command is enabled, the memory controller compares the key provided in fccob to the backdoor comparison key in the flash con?uration ?ld with key 0 compared to 0x3_ff00, etc. if the backdoor keys match, security will be released. if the backdoor keys do not match, security is not released and all future attempts to execute the verify backdoor access key command are aborted (set accerr) until a reset occurs. the ccif flag is set after the verify backdoor access key operation has completed. 30.4.6.12 set user margin level command the set user margin level command causes the memory controller to set the margin level for future read operations of the p-flash or eeprom block. table 30-52. verify backdoor access key command fccob requirements ccobix[2:0] fccob parameters 000 0x0c not required 001 key 0 010 key 1 011 key 2 100 key 3 table 30-53. verify backdoor access key command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 100 at command launch set if an incorrect backdoor key is supplied set if backdoor key access has not been enabled (keyen[1:0] != 10, see section 30.3.2.2 ) set if the backdoor key has mismatched since the last reset fpviol none mgstat1 none mgstat0 none table 30-54. set user margin level command fccob requirements ccobix[2:0] fccob parameters 000 0x0d flash block selection code [1:0] . see table 30-34 001 margin level setting.
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1129 upon clearing ccif to launch the set user margin level command, the memory controller will set the user margin level for the targeted block and then set the ccif ?g. note when the eeprom block is targeted, the eeprom user margin levels are applied only to the eeprom reads. however, when the p-flash block is targeted, the p-flash user margin levels are applied to both p-flash and eeprom reads. it is not possible to apply user margin levels to the p-flash block only. valid margin level settings for the set user margin level command are de?ed in table 30-55 . note user margin levels can be used to check that flash memory contents have adequate margin for normal level read operations. if unexpected results are encountered when checking flash memory contents at user margin levels, a potential loss of information has been detected. 30.4.6.13 set field margin level command the set field margin level command, valid in special modes only, causes the memory controller to set the margin level speci?d for future read operations of the p-flash or eeprom block. table 30-55. valid set user margin level settings ccob (ccobix=001) level description 0x0000 return to normal level 0x0001 user margin-1 level 1 1 read margin to the erased state 0x0002 user margin-0 level 2 2 read margin to the programmed state table 30-56. set user margin level command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch. set if command not available in current mode (see table 30-27 ). set if an invalid margin level setting is supplied. fpviol none mgstat1 none mgstat0 none
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 1130 freescale semiconductor upon clearing ccif to launch the set field margin level command, the memory controller will set the ?ld margin level for the targeted block and then set the ccif ?g. note when the eeprom block is targeted, the eeprom ?ld margin levels are applied only to the eeprom reads. however, when the p-flash block is targeted, the p-flash ?ld margin levels are applied to both p-flash and eeprom reads. it is not possible to apply ?ld margin levels to the p-flash block only. valid margin level settings for the set field margin level command are de?ed in table 30-58 . table 30-57. set field margin level command fccob requirements ccobix[2:0] fccob parameters 000 0x0e flash block selection code [1:0] . see table 30-34 001 margin level setting. table 30-58. valid set field margin level settings ccob (ccobix=001) level description 0x0000 return to normal level 0x0001 user margin-1 level 1 1 read margin to the erased state 0x0002 user margin-0 level 2 2 read margin to the programmed state 0x0003 field margin-1 level 1 0x0004 field margin-0 level 2 table 30-59. set field margin level command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch. set if command not available in current mode (see table 30-27 ). set if an invalid margin level setting is supplied. fpviol none mgstat1 none mgstat0 none
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1131 caution field margin levels must only be used during verify of the initial factory programming. note field margin levels can be used to check that flash memory contents have adequate margin for data retention at the normal level setting. if unexpected results are encountered when checking flash memory contents at ?ld margin levels, the flash memory contents should be erased and reprogrammed. 30.4.6.14 erase verify eeprom section command the erase verify eeprom section command will verify that a section of code in the eeprom is erased. the erase verify eeprom section command de?es the starting point of the data to be veri?d and the number of words. upon clearing ccif to launch the erase verify eeprom section command, the memory controller will verify the selected section of eeprom memory is erased. the ccif ?g will set after the erase verify eeprom section operation has completed. if the section is not erased, it means blank check failed, both mgstat bits will be set. table 30-60. erase verify eeprom section command fccob requirements ccobix[2:0] fccob parameters 000 0x10 global address [17:16] to identify the eeprom block 001 global address [15:0] of the ?st word to be veri?d 010 number of words to be veri?d table 30-61. erase verify eeprom section command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 010 at command launch set if command not available in current mode (see table 30-27 ) set if an invalid global address [17:0] is supplied set if a misaligned word address is supplied (global address [0] != 0) set if the requested section breaches the end of the eeprom block fpviol none mgstat1 set if any errors have been encountered during the read or if blank check failed. mgstat0 set if any non-correctable errors have been encountered during the read or if blank check failed.
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 1132 freescale semiconductor 30.4.6.15 program eeprom command the program eeprom operation programs one to four previously erased words in the eeprom block. the program eeprom operation will con?m that the targeted location(s) were successfully programmed upon completion. caution a flash word must be in the erased state before being programmed. cumulative programming of bits within a flash word is not allowed. upon clearing ccif to launch the program eeprom command, the user-supplied words will be transferred to the memory controller and be programmed if the area is unprotected. the ccobix index value at program eeprom command launch determines how many words will be programmed in the eeprom block. the ccif ?g is set when the operation has completed. 30.4.6.16 erase eeprom sector command the erase eeprom sector operation will erase all addresses in a sector of the eeprom block. table 30-62. program eeprom command fccob requirements ccobix[2:0] fccob parameters 000 0x11 global address [17:16] to identify the eeprom block 001 global address [15:0] of word to be programmed 010 word 0 program value 011 word 1 program value, if desired 100 word 2 program value, if desired 101 word 3 program value, if desired table 30-63. program eeprom command error handling register error bit error condition fstat accerr set if ccobix[2:0] < 010 at command launch set if ccobix[2:0] > 101 at command launch set if command not available in current mode (see table 30-27 ) set if an invalid global address [17:0] is supplied set if a misaligned word address is supplied (global address [0] != 0) set if the requested group of words breaches the end of the eeprom block fpviol set if the selected area of the eeprom memory is protected mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1133 upon clearing ccif to launch the erase eeprom sector command, the memory controller will erase the selected flash sector and verify that it is erased. the ccif ?g will set after the erase eeprom sector operation has completed. 30.4.7 interrupts the flash module can generate an interrupt when a flash command operation has completed or when a flash command operation has detected an ecc fault. table 30-64. erase eeprom sector command fccob requirements ccobix[2:0] fccob parameters 000 0x12 global address [17:16] to identify eeprom block 001 global address [15:0] anywhere within the sector to be erased. see section 30.1.2.2 for eeprom sector size. table 30-65. erase eeprom sector command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 30-27 ) set if an invalid global address [17:0] is suppliedsee table 30-3 ) set if a misaligned word address is supplied (global address [0] != 0) fpviol set if the selected area of the eeprom memory is protected mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation table 30-66. flash interrupt sources interrupt source interrupt flag local enable global (ccr) mask flash command complete ccif (fstat register) ccie (fcnfg register) i bit ecc double bit fault on flash read dfdif (ferstat register) dfdie (fercnfg register) i bit ecc single bit fault on flash read sfdif (ferstat register) sfdie (fercnfg register) i bit
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 1134 freescale semiconductor note vector addresses and their relative interrupt priority are determined at the mcu level. 30.4.7.1 description of flash interrupt operation the flash module uses the ccif ?g in combination with the ccie interrupt enable bit to generate the flash command interrupt request. the flash module uses the dfdif and sfdif ?gs in combination with the dfdie and sfdie interrupt enable bits to generate the flash error interrupt request. for a detailed description of the register bits involved, refer to section 30.3.2.5, ?lash configuration register (fcnfg) ? section 30.3.2.6, ?lash error configuration register (fercnfg) ? section 30.3.2.7, ?lash status register (fstat) ? and section 30.3.2.8, ?lash error status register (ferstat) ? the logic used for generating the flash module interrupts is shown in figure 30-27 . figure 30-27. flash module interrupts implementation 30.4.8 wait mode the flash module is not affected if the mcu enters wait mode. the flash module can recover the mcu from wait via the ccif interrupt (see section 30.4.7, ?nterrupts ). 30.4.9 stop mode if a flash command is active (ccif = 0) when the mcu requests stop mode, the current flash operation will be completed before the mcu is allowed to enter stop mode. flash error interrupt request ccif ccie dfdif dfdie sfdif sfdie flash command interrupt request
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1135 30.5 security the flash module provides security information to the mcu. the flash security state is de?ed by the sec bits of the fsec register (see table 30-11 ). during reset, the flash module initializes the fsec register using data read from the security byte of the flash con?uration ?ld at global address 0x3_ff0f. the security state out of reset can be permanently changed by programming the security byte assuming that the mcu is starting from a mode where the necessary p-flash erase and program commands are available and that the upper region of the p-flash is unprotected. if the flash security byte is successfully programmed, its new value will take affect after the next mcu reset. the following subsections describe these security-related subjects: unsecuring the mcu using backdoor key access unsecuring the mcu in special single chip mode using bdm mode and security effects on flash command availability 30.5.1 unsecuring the mcu using backdoor key access the mcu may be unsecured by using the backdoor key access feature which requires knowledge of the contents of the backdoor keys (four 16-bit words programmed at addresses 0x3_ff00-0x3_ff07). if the keyen[1:0] bits are in the enabled state (see section 30.3.2.2 ), the verify backdoor access key command (see section 30.4.6.11 ) allows the user to present four prospective keys for comparison to the keys stored in the flash memory via the memory controller. if the keys presented in the verify backdoor access key command match the backdoor keys stored in the flash memory, the sec bits in the fsec register (see table 30-11 ) will be changed to unsecure the mcu. key values of 0x0000 and 0xffff are not permitted as backdoor keys. while the verify backdoor access key command is active, p-flash memory and eeprom memory will not be available for read access and will return invalid data. the user code stored in the p-flash memory must have a method of receiving the backdoor keys from an external stimulus. this external stimulus would typically be through one of the on-chip serial ports. if the keyen[1:0] bits are in the enabled state (see section 30.3.2.2 ), the mcu can be unsecured by the backdoor key access sequence described below: 1. follow the command sequence for the verify backdoor access key command as explained in section 30.4.6.11 2. if the verify backdoor access key command is successful, the mcu is unsecured and the sec[1:0] bits in the fsec register are forced to the unsecure state of 10 the verify backdoor access key command is monitored by the memory controller and an illegal key will prohibit future use of the verify backdoor access key command. a reset of the mcu is the only method to re-enable the verify backdoor access key command. the security as de?ed in the flash security byte (0x3_ff0f) is not changed by using the verify backdoor access key command sequence. the backdoor keys stored in addresses 0x3_ff00-0x3_ff07 are unaffected by the verify backdoor access key command sequence. the verify backdoor access key command sequence has no effect on the program and erase protections de?ed in the flash protection register, fprot. after the backdoor keys have been correctly matched, the mcu will be unsecured. after the mcu is unsecured, the sector containing the flash security byte can be erased and the flash security byte can be
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 1136 freescale semiconductor reprogrammed to the unsecure state, if desired. in the unsecure state, the user has full control of the contents of the backdoor keys by programming addresses 0x3_ff00-0x3_ff07 in the flash con?uration ?ld. 30.5.2 unsecuring the mcu in special single chip mode using bdm a secured mcu can be unsecured in special single chip mode by using the following method to erase the p-flash and eeprom memory: 1. reset the mcu into special single chip mode 2. delay while the bdm executes the erase verify all blocks command write sequence to check if the p-flash and eeprom memories are erased 3. send bdm commands to disable protection in the p-flash and eeprom memory 4. execute the erase all blocks command write sequence to erase the p-flash and eeprom memory. alternatively the unsecure flash command can be executed, if so the steps 5 and 6 below are skeeped. 5. after the ccif ?g sets to indicate that the erase all blocks operation has completed, reset the mcu into special single chip mode 6. delay while the bdm executes the erase verify all blocks command write sequence to verify that the p-flash and eeprom memory are erased if the p-flash and eeprom memory are veri?d as erased, the mcu will be unsecured. all bdm commands will now be enabled and the flash security byte may be programmed to the unsecure state by continuing with the following steps: 7. send bdm commands to execute the program p-flash command write sequence to program the flash security byte to the unsecured state 8. reset the mcu 30.5.3 mode and security effects on flash command availability the availability of flash module commands depends on the mcu operating mode and security state as shown in table 30-27 . 30.6 initialization on each system reset the ?sh module executes an initialization sequence which establishes initial values for the flash block con?uration parameters, the fprot and eeprot protection registers, and the fopt and fsec registers. the initialization routine reverts to built-in default values that leave the module in a fully protected and secured state if errors are encountered during execution of the reset sequence. if a double bit fault is detected during the reset sequence, both mgstat bits in the fstat register will be set. ccif is cleared throughout the initialization sequence. the flash module holds off all cpu access for a portion of the initialization sequence. flash reads are allowed once the hold is removed. completion of the initialization sequence is marked by setting ccif high which enables user commands.
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1137 if a reset occurs while any flash command is in progress, that command will be immediately aborted. the state of the word being programmed or the sector/block being erased is not guaranteed.
192 kbyte flash module (s12ftmrg192k2v1) mc9s12g family reference manual, rev.1.23 1138 freescale semiconductor
mc9s12g family reference manual, rev.1.23 freescale semiconductor 1139 chapter 31 240 kbyte flash module (s12ftmrg240k2v1) 31.1 introduction the ftmrg240k2 module implements the following: 240kbytes of p-flash (program flash) memory 4kbytes of eeprom memory the flash memory is ideal for single-supply applications allowing for ?ld reprogramming without requiring external high voltage sources for program or erase operations. the flash module includes a memory controller that executes commands to modify flash memory contents. the user interface to the memory controller consists of the indexed flash common command object (fccob) register which is written to with the command, global address, data, and any required command parameters. the memory controller must complete the execution of a command before the fccob register can be written to with a new command. caution a flash word or phrase must be in the erased state before being programmed. cumulative programming of bits within a flash word or phrase is not allowed. table 31-1. revision history revision number revision date sections affected description of changes v01.06 23 jun 2010 31.4.6.2/31-117 3 31.4.6.12/31-11 80 31.4.6.13/31-11 81 updated description of the commands rd1blk, mloadu and mloadf v01.07 20 aug 2010 31.4.6.2/31-117 3 31.4.6.12/31-11 80 31.4.6.13/31-11 81 updated description of the commands rd1blk, mloadu and mloadf rev.1.23 31 jan 2011 31.3.2.9/31-115 6 updated description of protection on section 31.3.2.9
mc9s12g family reference manual, rev.1.23 freescale semiconductor 1140 the flash memory may be read as bytes and aligned words. read access time is one bus cycle for bytes and aligned words. for misaligned words access, the cpu has to perform twice the byte read access command. for flash memory, an erased bit reads 1 and a programmed bit reads 0. it is possible to read from p-flash memory while some commands are executing on eeprom memory. it is not possible to read from eeprom memory while a command is executing on p-flash memory. simultaneous p-flash and eeprom operations are discussed in section 31.4.5 . both p-flash and eeprom memories are implemented with error correction codes (ecc) that can resolve single bit faults and detect double bit faults. for p-flash memory, the ecc implementation requires that programming be done on an aligned 8 byte basis (a flash phrase). since p-flash memory is always read by half-phrase, only one single bit fault in an aligned 4 byte half-phrase containing the byte or word accessed will be corrected. 31.1.1 glossary command write sequence ?an mcu instruction sequence to execute built-in algorithms (including program and erase) on the flash memory. eeprom memory ?the eeprom memory constitutes the nonvolatile memory store for data. eeprom sector ?the eeprom sector is the smallest portion of the eeprom memory that can be erased. the eeprom sector consists of 4 bytes. nvm command mode an nvm mode using the cpu to setup the fccob register to pass parameters required for flash command execution. phrase ?an aligned group of four 16-bit words within the p-flash memory. each phrase includes two sets of aligned double words with each set including 7 ecc bits for single bit fault correction and double bit fault detection within each double word. p-flash memory the p-flash memory constitutes the main nonvolatile memory store for applications. p-flash sector ?the p-flash sector is the smallest portion of the p-flash memory that can be erased. each p-flash sector contains 512 bytes. program ifr ?nonvolatile information register located in the p-flash block that contains the version id, and the program once ?ld. 31.1.2 features 31.1.2.1 p-flash features 240 kbytes of p-flash memory divided into 480 sectors of 512 bytes
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1141 single bit fault correction and double bit fault detection within a 32-bit double word during read operations automated program and erase algorithm with verify and generation of ecc parity bits fast sector erase and phrase program operation ability to read the p-flash memory while programming a word in the eeprom memory flexible protection scheme to prevent accidental program or erase of p-flash memory 31.1.2.2 eeprom features 4 kbytes of eeprom memory composed of one 4 kbyte flash block divided into 1024 sectors of 4 bytes single bit fault correction and double bit fault detection within a word during read operations automated program and erase algorithm with verify and generation of ecc parity bits fast sector erase and word program operation protection scheme to prevent accidental program or erase of eeprom memory ability to program up to four words in a burst sequence 31.1.2.3 other flash module features no external high-voltage power supply required for flash memory program and erase operations interrupt generation on flash command completion and flash error detection security mechanism to prevent unauthorized access to the flash memory 31.1.3 block diagram the block diagram of the flash module is shown in figure 31-1 .
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 1142 freescale semiconductor figure 31-1. ftmrg240k2 block diagram 31.2 external signal description the flash module contains no signals that connect off-chip. bus clock divider clock command interrupt request fclk protection security registers flash interface 16bit internal bus sector 0 sector 1 sector 479 60kx39 p-flash error interrupt request cpu sector 0 sector 1 sector 1023 2kx22 eeprom memory controller
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1143 31.3 memory map and registers this section describes the memory map and registers for the flash module. read data from unimplemented memory space in the flash module is unde?ed. write access to unimplemented or reserved memory space in the flash module will be ignored by the flash module. caution writing to the flash registers while a flash command is executing (that is indicated when the value of ?g ccif reads as ?? is not allowed. if such action is attempted the write operation will not change the register value. writing to the flash registers is allowed when the flash is not busy executing commands (ccif = 1) and during initialization right after reset, despite the value of ?g ccif in that case (refer to section 31.6 for a complete description of the reset sequence). . 31.3.1 module memory map the s12 architecture places the p-flash memory between global addresses 0x0_4000 and 0x3_ffff as shown in table 31-3 .the p-flash memory map is shown in figure 31-2 . table 31-2. ftmrg memory map global address (in bytes) size (bytes) description 0x0_0000 - 0x0_03ff 1,024 register space 0x0_0400 ?0x0_13ff 4,096 eeprom memory 0x0_4000 ?0x0_7fff 16,284 nvmres=0 : p-flash memory area active 0x0_4000 ?0x0_7fff 16,284 nvmres 1 =1 : nvm resource area (see figure 31-3 ) 1 see nvmres description in section 31.4.3 0x0_8000 ?0x3_ffff 229,376 p-flash memory
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 1144 freescale semiconductor the fprot register, described in section 31.3.2.9 , can be set to protect regions in the flash memory from accidental program or erase. the flash memory addresses covered by these protectable regions are shown in the p-flash memory map. the higher address region is mainly targeted to hold the boot loader code since it covers the vector space. default protection settings as well as security information that allows the mcu to restrict access to the flash module are stored in the flash con?uration ?ld as described in table 31-4 . table 31-3. p-flash memory addressing global address size (bytes) description 0x0_4000 ?0x3_ffff 240 k p-flash block contains flash con?uration field (see table 31-4 ). table 31-4. flash con?uration field global address size (bytes) description 0x3_ff00-0x3_ff07 8 backdoor comparison key refer to section 31.4.6.11, ?erify backdoor access key command , and section 31.5.1, ?nsecuring the mcu using backdoor key access 0x3_ff08-0x3_ff0b 1 1 0x3ff08-0x3_ff0f form a flash phrase and must be programmed in a single command write sequence. each byte in the 0x3_ff08 - 0x3_ff0b reserved ?ld should be programmed to 0xff. 4 reserved 0x3_ff0c 1 1 p-flash protection byte . refer to section 31.3.2.9, ?-flash protection register (fprot) 0x3_ff0d 1 1 eeprom protection byte . refer to section 31.3.2.10, ?eprom protection register (eeprot) 0x3_ff0e 1 1 flash nonvolatile byte refer to section 31.3.2.16, ?lash option register (fopt) 0x3_ff0f 1 1 flash security byte refer to section 31.3.2.2, ?lash security register (fsec)
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1145 figure 31-2. p-flash memory map table 31-5. program ifr fields global address size (bytes) field description 0x0_4000 ?0x0_4007 8 reserved 0x0_4008 ?0x0_40b5 174 reserved 0x0_40b6 ?0x0_40b7 2 version id 1 flash con?uration field 0x3_c000 flash protected/unprotected lower region 1, 2, 4, 8 kbytes 0x3_8000 0x3_9000 0x3_8400 0x3_8800 0x3_a000 p-flash end = 0x3_ffff 0x3_f800 0x3_f000 0x3_e000 flash protected/unprotected higher region 2, 4, 8, 16 kbytes flash protected/unprotected region 8 kbytes (up to 29 kbytes) 16 bytes (0x3_ff00 - 0x3_ff0f) flash protected/unprotected region 208 kbytes p-flash start = 0x0_4000 protection protection protection movable end fixed end fixed end
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 1146 freescale semiconductor figure 31-3. memory controller resource memory map (nvmres=1) 0x0_40b8 ?0x0_40bf 8 reserved 0x0_40c0 ?0x0_40ff 64 program once field refer to section 31.4.6.6, ?rogram once command 1 used to track ?mware patch versions, see section 31.4.2 table 31-6. memory controller resource fields (nvmres 1 =1) 1 nvmres - see section 31.4.3 for nvmres (nvm resource) detail. global address size (bytes) description 0x0_4000 ?0x040ff 256 p-flash ifr (see table 31-5 ) 0x0_4100 ?0x0_41ff 256 reserved. 0x0_4200 ?0x0_57ff reserved 0x0_5800 ?0x0_5aff 768 reserved 0x0_5b00 ?0x0_5fff 1,280 reserved 0x0_6000 ?0x0_67ff 2,048 reserved 0x0_6800 ?0x0_7fff 6,144 reserved table 31-5. program ifr fields global address size (bytes) field description p-flash ifr 128 bytes (nvmres=1) 0x0_4000 reserved 6144 bytes reserved 3328 bytes 0x0_6800 0x0_7fff 0x0_4100 reserved 5632 bytes reserved 768 bytes 0x0_4200 reserved 128 bytes 0x0_5800 0x0_5aff
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1147 31.3.2 register descriptions the flash module contains a set of 20 control and status registers located between flash module base + 0x0000 and 0x0013. in the case of the writable registers, the write accesses are forbidden during fash command execution (for more detail, see caution note in section 31.3 ). a summary of the flash module registers is given in figure 31-4 with detailed descriptions in the following subsections. address & name 76543210 0x0000 fclkdiv r fdivld fdivlck fdiv5 fdiv4 fdiv3 fdiv2 fdiv1 fdiv0 w 0x0001 fsec r keyen1 keyen0 rnv5 rnv4 rnv3 rnv2 sec1 sec0 w 0x0002 fccobix r0 0 0 0 0 ccobix2 ccobix1 ccobix0 w 0x0003 frsv0 r00000000 w 0x0004 fcnfg r ccie 00 ignsf 00 fdfd fsfd w 0x0005 fercnfg r0 0 0 0 0 0 dfdie sfdie w 0x0006 fstat r ccif 0 accerr fpviol mgbusy rsvd mgstat1 mgstat0 w 0x0007 ferstat r0 0 0 0 0 0 dfdif sfdif w 0x0008 fprot r fpopen rnv6 fphdis fphs1 fphs0 fpldis fpls1 fpls0 w 0x0009 eeprot r dpopen dps6 dps5 dps4 dps3 dps2 dps1 dps0 w figure 31-4. ftmrg240k2 register summary
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 1148 freescale semiconductor 31.3.2.1 flash clock divider register (fclkdiv) the fclkdiv register is used to control timed events in program and erase algorithms. 0x000a fccobhi r ccob15 ccob14 ccob13 ccob12 ccob11 ccob10 ccob9 ccob8 w 0x000b fccoblo r ccob7 ccob6 ccob5 ccob4 ccob3 ccob2 ccob1 ccob0 w 0x000c frsv1 r00000000 w 0x000d frsv2 r00000000 w 0x000e frsv3 r00000000 w 0x000f frsv4 r00000000 w 0x0010 fopt r nv7 nv6 nv5 nv4 nv3 nv2 nv1 nv0 w 0x0011 frsv5 r00000000 w 0x0012 frsv6 r00000000 w 0x0013 frsv7 r00000000 w = unimplemented or reserved address & name 76543210 figure 31-4. ftmrg240k2 register summary (continued)
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1149 all bits in the fclkdiv register are readable, bit 7 is not writable, bit 6 is write-once-hi and controls the writability of the fdiv ?ld in normal mode. in special mode, bits 6-0 are writable any number of times but bit 7 remains unwritable. caution the fclkdiv register should never be written while a flash command is executing (ccif=0). offset module base + 0x0000 76543210 r fdivld fdivlck fdiv[5:0] w reset 00000000 = unimplemented or reserved figure 31-5. flash clock divider register (fclkdiv) table 31-7. fclkdiv field descriptions field description 7 fdivld clock divider loaded 0 fclkdiv register has not been written since the last reset 1 fclkdiv register has been written since the last reset 6 fdivlck clock divider locked 0 fdiv ?ld is open for writing 1 fdiv value is locked and cannot be changed. once the lock bit is set high, only reset can clear this bit and restore writability to the fdiv ?ld in normal mode. 5? fdiv[5:0] clock divider bits fdiv[5:0] must be set to effectively divide busclk down to 1 mhz to control timed events during flash program and erase algorithms. table 31-8 shows recommended values for fdiv[5:0] based on the busclk frequency. please refer to section 31.4.4, ?lash command operations , for more information.
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 1150 freescale semiconductor 31.3.2.2 flash security register (fsec) the fsec register holds all bits associated with the security of the mcu and flash module. all bits in the fsec register are readable but not writable. during the reset sequence, the fsec register is loaded with the contents of the flash security byte in the flash con?uration ?ld at global address 0x3_ff0f located in p-flash memory (see table 31-4 ) as table 31-8. fdiv values for various busclk frequencies busclk frequency (mhz) fdiv[5:0] busclk frequency (mhz) fdiv[5:0] min 1 1 busclk is greater than this value. max 2 2 busclk is less than or equal to this value. min 1 max 2 1.0 1.6 0x00 16.6 17.6 0x10 1.6 2.6 0x01 17.6 18.6 0x11 2.6 3.6 0x02 18.6 19.6 0x12 3.6 4.6 0x03 19.6 20.6 0x13 4.6 5.6 0x04 20.6 21.6 0x14 5.6 6.6 0x05 21.6 22.6 0x15 6.6 7.6 0x06 22.6 23.6 0x16 7.6 8.6 0x07 23.6 24.6 0x17 8.6 9.6 0x08 24.6 25.6 0x18 9.6 10.6 0x09 10.6 11.6 0x0a 11.6 12.6 0x0b 12.6 13.6 0x0c 13.6 14.6 0x0d 14.6 15.6 0x0e 15.6 16.6 0x0f offset module base + 0x0001 76543210 r keyen[1:0] rnv[5:2] sec[1:0] w reset f 1 1 loaded from ifr flash con?uration ?ld, during reset sequence. f 1 f 1 f 1 f 1 f 1 f 1 f 1 = unimplemented or reserved figure 31-6. flash security register (fsec)
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1151 indicated by reset condition f in figure 31-6 . if a double bit fault is detected while reading the p-flash phrase containing the flash security byte during the reset sequence, all bits in the fsec register will be set to leave the flash module in a secured state with backdoor key access disabled. the security function in the flash module is described in section 31.5 . 31.3.2.3 flash ccob index register (fccobix) the fccobix register is used to index the fccob register for flash memory operations. table 31-9. fsec field descriptions field description 7? keyen[1:0] backdoor key security enable bits the keyen[1:0] bits de?e the enabling of backdoor key access to the flash module as shown in table 31-10 . 5? rnv[5:2] reserved nonvolatile bits ?the rnv bits should remain in the erased state for future enhancements. 1? sec[1:0] flash security bits ?the sec[1:0] bits de?e the security state of the mcu as shown in table 31-11 . if the flash module is unsecured using backdoor key access, the sec bits are forced to 10. table 31-10. flash keyen states keyen[1:0] status of backdoor key access 00 disabled 01 disabled 1 1 preferred keyen state to disable backdoor key access. 10 enabled 11 disabled table 31-11. flash security states sec[1:0] status of security 00 secured 01 secured 1 1 preferred sec state to set mcu to secured state. 10 unsecured 11 secured offset module base + 0x0002 76543210 r00000 ccobix[2:0] w reset 00000000 = unimplemented or reserved figure 31-7. fccob index register (fccobix)
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 1152 freescale semiconductor ccobix bits are readable and writable while remaining bits read 0 and are not writable. 31.3.2.4 flash reserved0 register (frsv0) this flash register is reserved for factory testing. all bits in the frsv0 register read 0 and are not writable. 31.3.2.5 flash con?uration register (fcnfg) the fcnfg register enables the flash command complete interrupt and forces ecc faults on flash array read access from the cpu. ccie, ignsf, fdfd, and fsfd bits are readable and writable while remaining bits read 0 and are not writable. table 31-12. fccobix field descriptions field description 2? ccobix[1:0] common command register index the ccobix bits are used to select which word of the fccob register array is being read or written to. see 31.3.2.11 flash common command object register (fccob), for more details. offset module base + 0x000c 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 31-8. flash reserved0 register (frsv0) offset module base + 0x0004 76543210 r ccie 00 ignsf 00 fdfd fsfd w reset 00000000 = unimplemented or reserved figure 31-9. flash con?uration register (fcnfg)
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1153 31.3.2.6 flash error con?uration register (fercnfg) the fercnfg register enables the flash error interrupts for the ferstat ?gs. all assigned bits in the fercnfg register are readable and writable. table 31-13. fcnfg field descriptions field description 7 ccie command complete interrupt enable ?the ccie bit controls interrupt generation when a flash command has completed. 0 command complete interrupt disabled 1 an interrupt will be requested whenever the ccif ?g in the fstat register is set (see section 31.3.2.7 ) 4 ignsf ignore single bit fault ?the ignsf controls single bit fault reporting in the ferstat register (see section 31.3.2.8 ). 0 all single bit faults detected during array reads are reported 1 single bit faults detected during array reads are not reported and the single bit fault interrupt will not be generated 1 fdfd force double bit fault detect the fdfd bit allows the user to simulate a double bit fault during flash array read operations and check the associated interrupt routine. the fdfd bit is cleared by writing a 0 to fdfd. 0 flash array read operations will set the dfdif ?g in the ferstat register only if a double bit fault is detected 1 any flash array read operation will force the dfdif ?g in the ferstat register to be set (see section 31.3.2.7 ) and an interrupt will be generated as long as the dfdie interrupt enable in the fercnfg register is set (see section 31.3.2.6 ) 0 fsfd force single bit fault detect the fsfd bit allows the user to simulate a single bit fault during flash array read operations and check the associated interrupt routine. the fsfd bit is cleared by writing a 0 to fsfd. 0 flash array read operations will set the sfdif ?g in the ferstat register only if a single bit fault is detected 1 flash array read operation will force the sfdif ?g in the ferstat register to be set (see section 31.3.2.7 ) and an interrupt will be generated as long as the sfdie interrupt enable in the fercnfg register is set (see section 31.3.2.6 ) offset module base + 0x0005 76543210 r000000 dfdie sfdie w reset 00000000 = unimplemented or reserved figure 31-10. flash error con?uration register (fercnfg)
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 1154 freescale semiconductor 31.3.2.7 flash status register (fstat) the fstat register reports the operational status of the flash module. ccif, accerr, and fpviol bits are readable and writable, mgbusy and mgstat bits are readable but not writable, while remaining bits read 0 and are not writable. table 31-14. fercnfg field descriptions field description 1 dfdie double bit fault detect interrupt enable the dfdie bit controls interrupt generation when a double bit fault is detected during a flash block read operation. 0 dfdif interrupt disabled 1 an interrupt will be requested whenever the dfdif ?g is set (see section 31.3.2.8 ) 0 sfdie single bit fault detect interrupt enable the sfdie bit controls interrupt generation when a single bit fault is detected during a flash block read operation. 0 sfdif interrupt disabled whenever the sfdif ?g is set (see section 31.3.2.8 ) 1 an interrupt will be requested whenever the sfdif ?g is set (see section 31.3.2.8 ) offset module base + 0x0006 76543210 r ccif 0 accerr fpviol mgbusy rsvd mgstat[1:0] w reset 1000000 1 1 reset value can deviate from the value shown if a double bit fault is detected during the reset sequence (see section 31.6 ). 0 1 = unimplemented or reserved figure 31-11. flash status register (fstat) table 31-15. fstat field descriptions field description 7 ccif command complete interrupt flag ?the ccif ?g indicates that a flash command has completed. the ccif ?g is cleared by writing a 1 to ccif to launch a command and ccif will stay low until command completion or command violation. 0 flash command in progress 1 flash command has completed 5 accerr flash access error flag ?the accerr bit indicates an illegal access has occurred to the flash memory caused by either a violation of the command write sequence (see section 31.4.4.2 ) or issuing an illegal flash command. while accerr is set, the ccif ?g cannot be cleared to launch a command. the accerr bit is cleared by writing a 1 to accerr. writing a 0 to the accerr bit has no effect on accerr. 0 no access error detected 1 access error detected 4 fpviol flash protection violation flag ?he fpviol bit indicates an attempt was made to program or erase an address in a protected area of p-flash or eeprom memory during a command write sequence. the fpviol bit is cleared by writing a 1 to fpviol. writing a 0 to the fpviol bit has no effect on fpviol. while fpviol is set, it is not possible to launch a command or start a command write sequence. 0 no protection violation detected 1 protection violation detected
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1155 31.3.2.8 flash error status register (ferstat) the ferstat register re?cts the error status of internal flash operations. all ?gs in the ferstat register are readable and only writable to clear the ?g. 3 mgbusy memory controller busy flag ?the mgbusy ?g re?cts the active state of the memory controller . 0 memory controller is idle 1 memory controller is busy executing a flash command (ccif = 0) 2 rsvd reserved bit ?this bit is reserved and always reads 0 . 1? mgstat[1:0] memory controller command completion status flag one or more mgstat ?g bits are set if an error is detected during execution of a flash command or during the flash reset sequence. see section 31.4.6, ?lash command description , and section 31.6, ?nitialization ?for details. offset module base + 0x0007 76543210 r000000 dfdif sfdif w reset 00000000 = unimplemented or reserved figure 31-12. flash error status register (ferstat) table 31-16. ferstat field descriptions field description 1 dfdif double bit fault detect interrupt flag ?the setting of the dfdif ?g indicates that a double bit fault was detected in the stored parity and data bits during a flash array read operation or that a flash array read operation returning invalid data was attempted on a flash block that was under a flash command operation. 1 the dfdif ?g is cleared by writing a 1 to dfdif. writing a 0 to dfdif has no effect on dfdif. 2 0 no double bit fault detected 1 double bit fault detected or a flash array read operation returning invalid data was attempted while command running 1 the single bit fault and double bit fault ?gs are mutually exclusive for parity errors (an ecc fault occurrence can be either single fault or double fault but never both). a simultaneous access collision (flash array read operation returning invalid data attempted while command running) is indicated when both sfdif and dfdif ?gs are high. 2 there is a one cycle delay in storing the ecc dfdif and sfdif fault ?gs in this register. at least one nop is required after a ?sh memory read before checking ferstat for the occurrence of ecc errors. 0 sfdif single bit fault detect interrupt flag ?with the ignsf bit in the fcnfg register clear, the sfdif ?g indicates that a single bit fault was detected in the stored parity and data bits during a flash array read operation or that a flash array read operation returning invalid data was attempted on a flash block that was under a flash command operation. 1 the sfdif ?g is cleared by writing a 1 to sfdif. writing a 0 to sfdif has no effect on sfdif. 0 no single bit fault detected 1 single bit fault detected and corrected or a flash array read operation returning invalid data was attempted while command running table 31-15. fstat field descriptions (continued) field description
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 1156 freescale semiconductor 31.3.2.9 p-flash protection register (fprot) the fprot register de?es which p-flash sectors are protected against program and erase operations. the (unreserved) bits of the fprot register are writable with the restriction that the size of the protected region can only be increased (see section 31.3.2.9.1, ?-flash protection restrictions , and table 31-21 ). during the reset sequence, the fprot register is loaded with the contents of the p-flash protection byte in the flash con?uration ?ld at global address 0x3_ff0c located in p-flash memory (see table 31-4 ) as indicated by reset condition ??in figure 31-13 . to change the p-flash protection that will be loaded during the reset sequence, the upper sector of the p-flash memory must be unprotected, then the p-flash protection byte must be reprogrammed. if a double bit fault is detected while reading the p-flash phrase containing the p-flash protection byte during the reset sequence, the fpopen bit will be cleared and remaining bits in the fprot register will be set to leave the p-flash memory fully protected. trying to alter data in any protected area in the p-flash memory will result in a protection violation error and the fpviol bit will be set in the fstat register. the block erase of a p-flash block is not possible if any of the p-flash sectors contained in the same p-flash block are protected. offset module base + 0x0008 76543210 r fpopen rnv6 fphdis fphs[1:0] fpldis fpls[1:0] w reset f 1 1 loaded from ifr flash con?uration ?ld, during reset sequence. f 1 f 1 f 1 f 1 f 1 f 1 f 1 = unimplemented or reserved figure 31-13. flash protection register (fprot) table 31-17. fprot field descriptions field description 7 fpopen flash protection operation enable ?the fpopen bit determines the protection function for program or erase operations as shown in table 31-18 for the p-flash block. 0 when fpopen is clear, the fphdis and fpldis bits de?e unprotected address ranges as speci?d by the corresponding fphs and fpls bits 1 when fpopen is set, the fphdis and fpldis bits enable protection for the address range speci?d by the corresponding fphs and fpls bits 6 rnv[6] reserved nonvolatile bit ?the rnv bit should remain in the erased state for future enhancements. 5 fphdis flash protection higher address range disable ?the fphdis bit determines whether there is a protected/unprotected area in a speci? region of the p-flash memory ending with global address 0x3_ffff. 0 protection/unprotection enabled 1 protection/unprotection disabled 4? fphs[1:0] flash protection higher address size the fphs bits determine the size of the protected/unprotected area in p-flash memory as shown in table 31-19 . the fphs bits can only be written to while the fphdis bit is set.
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1157 all possible p-flash protection scenarios are shown in figure 31-14 . although the protection scheme is loaded from the flash memory at global address 0x3_ff0c during the reset sequence, it can be changed by the user. the p-flash protection scheme can be used by applications requiring reprogramming in single chip mode while providing as much protection as possible if reprogramming is not required. 2 fpldis flash protection lower address range disable ?the fpldis bit determines whether there is a protected/unprotected area in a speci? region of the p-flash memory beginning with global address 0x3_8000. 0 protection/unprotection enabled 1 protection/unprotection disabled 1? fpls[1:0] flash protection lower address size the fpls bits determine the size of the protected/unprotected area in p-flash memory as shown in table 31-20 . the fpls bits can only be written to while the fpldis bit is set. table 31-18. p-flash protection function fpopen fphdis fpldis function 1 1 for range sizes, refer to table 31-19 and table 31-20 . 1 1 1 no p-flash protection 1 1 0 protected low range 1 0 1 protected high range 1 0 0 protected high and low ranges 0 1 1 full p-flash memory protected 0 1 0 unprotected low range 0 0 1 unprotected high range 0 0 0 unprotected high and low ranges table 31-19. p-flash protection higher address range fphs[1:0] global address range protected size 00 0x3_f800?x3_ffff 2 kbytes 01 0x3_f000?x3_ffff 4 kbytes 10 0x3_e000?x3_ffff 8 kbytes 11 0x3_c000?x3_ffff 16 kbytes table 31-20. p-flash protection lower address range fpls[1:0] global address range protected size 00 0x3_8000?x3_83ff 1 kbyte 01 0x3_8000?x3_87ff 2 kbytes 10 0x3_8000?x3_8fff 4 kbytes 11 0x3_8000?x3_9fff 8 kbytes table 31-17. fprot field descriptions (continued) field description
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 1158 freescale semiconductor figure 31-14. p-flash protection scenarios 7 6 5 4 fphs[1:0] fpls[1:0] 3 2 1 0 fphs[1:0] fpls[1:0] fphdis = 1 fpldis = 1 fphdis = 1 fpldis = 0 fphdis = 0 fpldis = 1 fphdis = 0 fpldis = 0 scenario scenario unprotected region protected region with size protected region protected region with size defined by fpls defined by fphs not defined by fpls, fphs 0x3_8000 0x3_ffff 0x3_8000 0x3_ffff flash start flash start fpopen = 1 fpopen = 0
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1159 31.3.2.9.1 p-flash protection restrictions the general guideline is that p-flash protection can only be added and not removed. table 31-21 speci?s all valid transitions between p-flash protection scenarios. any attempt to write an invalid scenario to the fprot register will be ignored. the contents of the fprot register re?ct the active protection scenario. see the fphs and fpls bit descriptions for additional restrictions. 31.3.2.10 eeprom protection register (eeprot) the eeprot register de?es which eeprom sectors are protected against program and erase operations. the (unreserved) bits of the eeprot register are writable with the restriction that protection can be added but not removed. writes must increase the dps value and the dpopen bit can only be written from 1 (protection disabled) to 0 (protection enabled). if the dpopen bit is set, the state of the dps bits is irrelevant. during the reset sequence, ?lds dpopen and dps of the eeprot register are loaded with the contents of the eeprom protection byte in the flash configuration field at global address 0x3_ff0d located in table 31-21. p-flash protection scenario transitions from protection scenario to protection scenario 1 1 allowed transitions marked with x, see figure 31-14 for a de?ition of the scenarios. 01234567 0 xxxx 1 xx 2 xx 3 x 4 xx 5 xxxx 6 xxxx 7 xxxxxxxx offset module base + 0x0009 76543210 r dpopen dps[6:0] w reset f 1 1 loaded from ifr flash con?uration ?ld, during reset sequence. f 1 f 1 f 1 f 1 f 1 f 1 f 1 figure 31-15. eeprom protection register (eeprot)
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 1160 freescale semiconductor p-flash memory (see table 31-4 ) as indicated by reset condition f in table 31-23 . to change the eeprom protection that will be loaded during the reset sequence, the p-flash sector containing the eeprom protection byte must be unprotected, then the eeprom protection byte must be programmed. if a double bit fault is detected while reading the p-flash phrase containing the eeprom protection byte during the reset sequence, the dpopen bit will be cleared and dps bits will be set to leave the eeprom memory fully protected. trying to alter data in any protected area in the eeprom memory will result in a protection violation error and the fpviol bit will be set in the fstat register. block erase of the eeprom memory is not possible if any of the eeprom sectors are protected. table 31-22. eeprot field descriptions field description 7 dpopen eeprom protection control 0 enables eeprom memory protection from program and erase with protected address range de?ed by dps bits 1 disables eeprom memory protection from program and erase 6? dps[6:0] eeprom protection size ?the dps[6:0] bits determine the size of the protected area in the eeprom memory, this size increase in step of 32 bytes, as shown in table 31-23 . table 31-23. eeprom protection address range dps[6:0] global address range protected size 0000000 0x0_0400 ?0x0_041f 32 bytes 0000001 0x0_0400 ?0x0_043f 64 bytes 0000010 0x0_0400 ?0x0_045f 96 bytes 0000011 0x0_0400 ?0x0_047f 128 bytes 0000100 0x0_0400 ?0x0_049f 160 bytes 0000101 0x0_0400 ?0x0_04bf 192 bytes the protection size goes on enlarging in step of 32 bytes, for each dps value increasing of one. . . . 1111111 0x0_0400 ?0x0_13ff 4,096 bytes
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1161 31.3.2.11 flash common command object register (fccob) the fccob is an array of six words addressed via the ccobix index found in the fccobix register. byte wide reads and writes are allowed to the fccob register. 31.3.2.11.1 fccob - nvm command mode nvm command mode uses the indexed fccob register to provide a command code and its relevant parameters to the memory controller. the user ?st sets up all required fccob ?lds and then initiates the commands execution by writing a 1 to the ccif bit in the fstat register (a 1 written by the user clears the ccif command completion ?g to 0). when the user clears the ccif bit in the fstat register all fccob parameter ?lds are locked and cannot be changed by the user until the command completes (as evidenced by the memory controller returning ccif to 1). some commands return information to the fccob register array. the generic format for the fccob parameter ?lds in nvm command mode is shown in table 31-24 . the return values are available for reading after the ccif ?g in the fstat register has been returned to 1 by the memory controller. writes to the unimplemented parameter ?lds (ccobix = 110 and ccobix = 111) are ignored with reads from these ?lds returning 0x0000. table 31-24 shows the generic flash command format. the high byte of the ?st word in the ccob array contains the command code, followed by the parameters for this speci? flash command. for details on the fccob settings required by each command, see the flash command descriptions in section 31.4.6 . offset module base + 0x000a 76543210 r ccob[15:8] w reset 00000000 figure 31-16. flash common command object high register (fccobhi) offset module base + 0x000b 76543210 r ccob[7:0] w reset 00000000 figure 31-17. flash common command object low register (fccoblo) table 31-24. fccob - nvm command mode (typical usage) ccobix[2:0] byte fccob parameter fields (nvm command mode) 000 hi fcmd[7:0] de?ing flash command lo 6?0, global address [17:16] 001 hi global address [15:8] lo global address [7:0]
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 1162 freescale semiconductor 31.3.2.12 flash reserved1 register (frsv1) this flash register is reserved for factory testing. all bits in the frsv1 register read 0 and are not writable. 31.3.2.13 flash reserved2 register (frsv2) this flash register is reserved for factory testing. all bits in the frsv2 register read 0 and are not writable. 31.3.2.14 flash reserved3 register (frsv3) this flash register is reserved for factory testing. 010 hi data 0 [15:8] lo data 0 [7:0] 011 hi data 1 [15:8] lo data 1 [7:0] 100 hi data 2 [15:8] lo data 2 [7:0] 101 hi data 3 [15:8] lo data 3 [7:0] offset module base + 0x000c 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 31-18. flash reserved1 register (frsv1) offset module base + 0x000d 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 31-19. flash reserved2 register (frsv2) table 31-24. fccob - nvm command mode (typical usage) ccobix[2:0] byte fccob parameter fields (nvm command mode)
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1163 all bits in the frsv3 register read 0 and are not writable. 31.3.2.15 flash reserved4 register (frsv4) this flash register is reserved for factory testing. all bits in the frsv4 register read 0 and are not writable. 31.3.2.16 flash option register (fopt) the fopt register is the flash option register. all bits in the fopt register are readable but are not writable. during the reset sequence, the fopt register is loaded from the flash nonvolatile byte in the flash con?uration ?ld at global address 0x3_ff0e located in p-flash memory (see table 31-4 ) as indicated by reset condition f in figure 31-22 . if a double bit fault is detected while reading the p-flash phrase containing the flash nonvolatile byte during the reset sequence, all bits in the fopt register will be set. offset module base + 0x000e 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 31-20. flash reserved3 register (frsv3) offset module base + 0x000f 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 31-21. flash reserved4 register (frsv4) offset module base + 0x0010 76543210 r nv[7:0] w reset f 1 1 loaded from ifr flash con?uration ?ld, during reset sequence. f 1 f 1 f 1 f 1 f 1 f 1 f 1 = unimplemented or reserved figure 31-22. flash option register (fopt)
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 1164 freescale semiconductor 31.3.2.17 flash reserved5 register (frsv5) this flash register is reserved for factory testing. all bits in the frsv5 register read 0 and are not writable. 31.3.2.18 flash reserved6 register (frsv6) this flash register is reserved for factory testing. all bits in the frsv6 register read 0 and are not writable. 31.3.2.19 flash reserved7 register (frsv7) this flash register is reserved for factory testing. table 31-25. fopt field descriptions field description 7? nv[7:0] nonvolatile bits the nv[7:0] bits are available as nonvolatile bits. refer to the device user guide for proper use of the nv bits. offset module base + 0x0011 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 31-23. flash reserved5 register (frsv5) offset module base + 0x0012 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 31-24. flash reserved6 register (frsv6)
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1165 all bits in the frsv7 register read 0 and are not writable. 31.4 functional description 31.4.1 modes of operation the ftmrg240k2 module provides the modes of operation normal and special . the operating mode is determined by module-level inputs and affects the fclkdiv, fcnfg, and eeprot registers (see table 31-27 ). 31.4.2 ifr version id word the version id word is stored in the ifr at address 0x0_40b6. the contents of the word are de?ed in table 31-26 . vernum: version number. the ?st version is number 0b_0001 with both 0b_0000 and 0b_1111 meaning ?one? offset module base + 0x0013 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 31-25. flash reserved7 register (frsv7) table 31-26. ifr version id fields [15:4] [3:0] reserved vernum
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 1166 freescale semiconductor 31.4.3 internal nvm resource (nvmres) ifr is an internal nvm resource readable by cpu , when nvmres is active. the ifr ?lds are shown in table 31-5 . the nvmres global address map is shown in table 31-6 . for ftmrg240k2 the nvmres address area is shared with 16k space of p-flash area, as shown in figure 31-2 . 31.4.4 flash command operations flash command operations are used to modify flash memory contents. the next sections describe: how to write the fclkdiv register that is used to generate a time base (fclk) derived from busclk for flash program and erase command operations the command write sequence used to set flash command parameters and launch execution valid flash commands available for execution, according to mcu functional mode and mcu security state. 31.4.4.1 writing the fclkdiv register prior to issuing any flash program or erase command after a reset, the user is required to write the fclkdiv register to divide busclk down to a target fclk of 1 mhz. table 31-8 shows recommended values for the fdiv ?ld based on busclk frequency. note programming or erasing the flash memory cannot be performed if the bus clock runs at less than 0.8 mhz. setting fdiv too high can destroy the flash memory due to overstress. setting fdiv too low can result in incomplete programming or erasure of the flash memory cells. when the fclkdiv register is written, the fdivld bit is set automatically. if the fdivld bit is 0, the fclkdiv register has not been written since the last reset. if the fclkdiv register has not been written, any flash program or erase command loaded during a command write sequence will not execute and the accerr bit in the fstat register will set. 31.4.4.2 command write sequence the memory controller will launch all valid flash commands entered using a command write sequence. before launching a command, the accerr and fpviol bits in the fstat register must be clear (see section 31.3.2.7 ) and the ccif ?g should be tested to determine the status of the current command write sequence. if ccif is 0, the previous command write sequence is still active, a new command write sequence cannot be started, and all writes to the fccob register are ignored.
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1167 31.4.4.2.1 de?e fccob contents the fccob parameter ?lds must be loaded with all required parameters for the flash command being executed. access to the fccob parameter ?lds is controlled via the ccobix bits in the fccobix register (see section 31.3.2.3 ). the contents of the fccob parameter ?lds are transferred to the memory controller when the user clears the ccif command completion ?g in the fstat register (writing 1 clears the ccif to 0). the ccif ?g will remain clear until the flash command has completed. upon completion, the memory controller will return ccif to 1 and the fccob register will be used to communicate any results. the ?w for a generic command write sequence is shown in figure 31-26 .
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 1168 freescale semiconductor figure 31-26. generic flash command write sequence flowchart write to fccobix register write: fstat register (to launch command) clear ccif 0x80 clear accerr/fpviol 0x30 write: fstat register yes no access error and protection violation read: fstat register start check fccob accerr/ fpviol set? exit write: fclkdiv register read: fclkdiv register yes no fdiv correct? no bit polling for command completion check yes ccif set? to identify speci? command parameter to load. write to fccob register to load required command parameter. yes no more parameters? availability check results from previous command note: fclkdiv must be set after each reset read: fstat register no yes ccif set? no yes ccif set? clock divider value check read: fstat register
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1169 31.4.4.3 valid flash module commands table 31-27 present the valid flash commands, as enabled by the combination of the functional mcu mode (normal singlechip ns, special singlechip ss) with the mcu security state (unsecured, secured). special singlechip mode is selected by input mmc_ss_mode_ts2 asserted. mcu secured state is selected by input mmc_secure input asserted. + 31.4.4.4 p-flash commands table 31-28 summarizes the valid p-flash commands along with the effects of the commands on the p-flash block and other resources within the flash module. table 31-27. flash commands by mode and security state fcmd command unsecured secured ns 1 1 unsecured normal single chip mode ss 2 2 unsecured special single chip mode. ns 3 3 secured normal single chip mode. ss 4 4 secured special single chip mode. 0x01 erase verify all blocks ???? 0x02 erase verify block ???? 0x03 erase verify p-flash section ??? 0x04 read once ??? 0x06 program p-flash ??? 0x07 program once ??? 0x08 erase all blocks ?? 0x09 erase flash block ??? 0x0a erase p-flash sector ??? 0x0b unsecure flash ?? 0x0c verify backdoor access key ?? 0x0d set user margin level ??? 0x0e set field margin level ? 0x10 erase verify eeprom section ??? 0x11 program eeprom ??? 0x12 erase eeprom sector ??? table 31-28. p-flash commands fcmd command function on p-flash memory 0x01 erase verify all blocks verify that all p-flash (and eeprom) blocks are erased.
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 1170 freescale semiconductor 31.4.4.5 eeprom commands table 31-29 summarizes the valid eeprom commands along with the effects of the commands on the eeprom block. 0x02 erase verify block verify that a p-flash block is erased. 0x03 erase verify p-flash section verify that a given number of words starting at the address provided are erased. 0x04 read once read a dedicated 64 byte ?ld in the nonvolatile information register in p-flash block that was previously programmed using the program once command. 0x06 program p-flash program a phrase in a p-flash block. 0x07 program once program a dedicated 64 byte ?ld in the nonvolatile information register in p-flash block that is allowed to be programmed only once. 0x08 erase all blocks erase all p-flash (and eeprom) blocks. an erase of all flash blocks is only possible when the fpldis, fphdis, and fpopen bits in the fprot register and the dpopen bit in the eeprot register are set prior to launching the command. 0x09 erase flash block erase a p-flash (or eeprom) block. an erase of the full p-flash block is only possible when fpldis, fphdis and fpopen bits in the fprot register are set prior to launching the command. 0x0a erase p-flash sector erase all bytes in a p-flash sector. 0x0b unsecure flash supports a method of releasing mcu security by erasing all p-flash (and eeprom) blocks and verifying that all p-flash (and eeprom) blocks are erased. 0x0c verify backdoor access key supports a method of releasing mcu security by verifying a set of security keys. 0x0d set user margin level speci?s a user margin read level for all p-flash blocks. 0x0e set field margin level speci?s a ?ld margin read level for all p-flash blocks (special modes only). table 31-29. eeprom commands fcmd command function on eeprom memory 0x01 erase verify all blocks verify that all eeprom (and p-flash) blocks are erased. 0x02 erase verify block verify that the eeprom block is erased. table 31-28. p-flash commands fcmd command function on p-flash memory
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1171 31.4.5 allowed simultaneous p-flash and eeprom operations only the operations marked ?k?in table 31-30 are permitted to be run simultaneously on the program flash and eeprom blocks. some operations cannot be executed simultaneously because certain hardware resources are shared by the two memories. the priority has been placed on permitting program flash reads while program and erase operations execute on the eeprom, providing read (p-flash) while write (eeprom) functionality. 0x08 erase all blocks erase all eeprom (and p-flash) blocks. an erase of all flash blocks is only possible when the fpldis, fphdis, and fpopen bits in the fprot register and the dpopen bit in the eeprot register are set prior to launching the command. 0x09 erase flash block erase a eeprom (or p-flash) block. an erase of the full eeprom block is only possible when dpopen bit in the eeprot register is set prior to launching the command. 0x0b unsecure flash supports a method of releasing mcu security by erasing all eeprom (and p-flash) blocks and verifying that all eeprom (and p-flash) blocks are erased. 0x0d set user margin level speci?s a user margin read level for the eeprom block. 0x0e set field margin level speci?s a ?ld margin read level for the eeprom block (special modes only). 0x10 erase verify eeprom section verify that a given number of words starting at the address provided are erased. 0x11 program eeprom program up to four words in the eeprom block. 0x12 erase eeprom sector erase all bytes in a sector of the eeprom block. table 31-30. allowed p-flash and eeprom simultaneous operations eeprom program flash read margin read 1 program sector erase mass erase 2 read ok ok ok margin read 1 1 a ?argin read?is any read after executing the margin setting commands ?et user margin level?or ?et field margin level?with anything but the ?ormal level speci?d. see the note on margin settings in section 31.4.6.12 and section 31.4.6.13 . program sector erase mass erase 2 2 the ?ass erase?operations are commands ?rase all blocks?and ?rase flash block ok table 31-29. eeprom commands fcmd command function on eeprom memory
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 1172 freescale semiconductor 31.4.6 flash command description this section provides details of all available flash commands launched by a command write sequence. the accerr bit in the fstat register will be set during the command write sequence if any of the following illegal steps are performed, causing the command not to be processed by the memory controller: starting any command write sequence that programs or erases flash memory before initializing the fclkdiv register writing an invalid command as part of the command write sequence for additional possible errors, refer to the error handling table provided for each command if a flash block is read during execution of an algorithm (ccif = 0) on that same block, the read operation will return invalid data if both ?gs sfdif and dfdif are set. if the sfdif or dfdif ?gs were not previously set when the invalid read operation occurred, both the sfdif and dfdif ?gs will be set. if the accerr or fpviol bits are set in the fstat register, the user must clear these bits before starting any command write sequence (see section 31.3.2.7 ). caution a flash word or phrase must be in the erased state before being programmed. cumulative programming of bits within a flash word or phrase is not allowed. 31.4.6.1 erase verify all blocks command the erase verify all blocks command will verify that all p-flash and eeprom blocks have been erased. upon clearing ccif to launch the erase verify all blocks command, the memory controller will verify that the entire flash memory space is erased. the ccif ?g will set after the erase verify all blocks operation has completed. if all blocks are not erased, it means blank check failed, both mgstat bits will be set. table 31-31. erase verify all blocks command fccob requirements ccobix[2:0] fccob parameters 000 0x01 not required table 31-32. erase verify all blocks command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 000 at command launch fpviol none mgstat1 set if any errors have been encountered during the reador if blank check failed . mgstat0 set if any non-correctable errors have been encountered during the read or if blank check failed.
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1173 31.4.6.2 erase verify block command the erase verify block command allows the user to verify that an entire p-flash or eeprom block has been erased. the fccob flashblockselectioncode[1:0]bits determine which block must be veri?d. upon clearing ccif to launch the erase verify block command, the memory controller will verify that the selected p-flash or eeprom block is erased. the ccif ?g will set after the erase verify block operation has completed.if the block is not erased, it means blank check failed, both mgstat bits will be set. 31.4.6.3 erase verify p-flash section command the erase verify p-flash section command will verify that a section of code in the p-flash memory is erased. the erase verify p-flash section command de?es the starting point of the code to be veri?d and the number of phrases. table 31-33. erase verify block command fccob requirements ccobix[2:0] fccob parameters 000 0x02 flash block selection code [1:0] . see table 31-34 table 31-34. flash block selection code description selection code[1:0] flash block to be veri?d 00 eeprom 01 p-flash 10 p-flash 11 p-flash table 31-35. erase verify block command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 000 at command launch. fpviol none. mgstat1 set if any errors have been encountered during the read or if blank check failed. mgstat0 set if any non-correctable errors have been encountered during the read 1 or if blank check failed.
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 1174 freescale semiconductor upon clearing ccif to launch the erase verify p-flash section command, the memory controller will verify the selected section of flash memory is erased. the ccif ?g will set after the erase verify p-flash section operation has completed. if the section is not erased, it means blank check failed, both mgstat bits will be set. 31.4.6.4 read once command the read once command provides read access to a reserved 64 byte ?ld (8 phrases) located in the nonvolatile information register of p-flash. the read once ?ld is programmed using the program once command described in section 31.4.6.6 . the read once command must not be executed from the flash block containing the program once reserved ?ld to avoid code runaway. table 31-36. erase verify p-flash section command fccob requirements ccobix[2:0] fccob parameters 000 0x03 global address [17:16] of a p-flash block 001 global address [15:0] of the ?st phrase to be veri?d 010 number of phrases to be veri?d table 31-37. erase verify p-flash section command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 010 at command launch set if command not available in current mode (see table 31-27 ) set if an invalid global address [17:0] is supplied see table 31-3 ) set if a misaligned phrase address is supplied (global address [2:0] != 000) set if the requested section crosses a the p-flash address boundary fpviol none mgstat1 set if any errors have been encountered during the read or if blank check failed. mgstat0 set if any non-correctable errors have been encountered during the read or if blank check failed. table 31-38. read once command fccob requirements ccobix[2:0] fccob parameters 000 0x04 not required 001 read once phrase index (0x0000 - 0x0007) 010 read once word 0 value 011 read once word 1 value 100 read once word 2 value 101 read once word 3 value
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1175 upon clearing ccif to launch the read once command, a read once phrase is fetched and stored in the fccob indexed register. the ccif ?g will set after the read once operation has completed. valid phrase index values for the read once command range from 0x0000 to 0x0007. during execution of the read once command, any attempt to read addresses within p-flash block will return invalid data. 8 31.4.6.5 program p-flash command the program p-flash operation will program a previously erased phrase in the p-flash memory using an embedded algorithm. caution a p-flash phrase must be in the erased state before being programmed. cumulative programming of bits within a flash phrase is not allowed. upon clearing ccif to launch the program p-flash command, the memory controller will program the data words to the supplied global address and will then proceed to verify the data words read back as expected. the ccif ?g will set after the program p-flash operation has completed. table 31-39. read once command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 31-27 ) set if an invalid phrase index is supplied fpviol none mgstat1 set if any errors have been encountered during the read mgstat0 set if any non-correctable errors have been encountered during the read table 31-40. program p-flash command fccob requirements ccobix[2:0] fccob parameters 000 0x06 global address [17:16] to identify p-flash block 001 global address [15:0] of phrase location to be programmed 1 1 global address [2:0] must be 000 010 word 0 program value 011 word 1 program value 100 word 2 program value 101 word 3 program value
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 1176 freescale semiconductor 31.4.6.6 program once command the program once command restricts programming to a reserved 64 byte ?ld (8 phrases) in the nonvolatile information register located in p-flash. the program once reserved ?ld can be read using the read once command as described in section 31.4.6.4 . the program once command must only be issued once since the nonvolatile information register in p-flash cannot be erased. the program once command must not be executed from the flash block containing the program once reserved ?ld to avoid code runaway. upon clearing ccif to launch the program once command, the memory controller ?st veri?s that the selected phrase is erased. if erased, then the selected phrase will be programmed and then veri?d with read back. the ccif ?g will remain clear, setting only after the program once operation has completed. the reserved nonvolatile information register accessed by the program once command cannot be erased and any attempt to program one of these phrases a second time will not be allowed. valid phrase index values for the program once command range from 0x0000 to 0x0007. during execution of the program once command, any attempt to read addresses within p-flash will return invalid data. table 31-41. program p-flash command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 101 at command launch set if command not available in current mode (see table 31-27 ) set if an invalid global address [17:0] is supplied see table 31-3 ) set if a misaligned phrase address is supplied (global address [2:0] != 000) fpviol set if the global address [17:0] points to a protected area mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation table 31-42. program once command fccob requirements ccobix[2:0] fccob parameters 000 0x07 not required 001 program once phrase index (0x0000 - 0x0007) 010 program once word 0 value 011 program once word 1 value 100 program once word 2 value 101 program once word 3 value
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1177 31.4.6.7 erase all blocks command the erase all blocks operation will erase the entire p-flash and eeprom memory space. upon clearing ccif to launch the erase all blocks command, the memory controller will erase the entire flash memory space and verify that it is erased. if the memory controller veri?s that the entire flash memory space was properly erased, security will be released. during the execution of this command (ccif=0) the user must not write to any flash module register. the ccif ?g will set after the erase all blocks operation has completed. 31.4.6.8 erase flash block command the erase flash block operation will erase all addresses in a p-flash or eeprom block. table 31-43. program once command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 101 at command launch set if command not available in current mode (see table 31-27 ) set if an invalid phrase index is supplied set if the requested phrase has already been programmed 1 1 if a program once phrase is initially programmed to 0xffff_ffff_ffff_ffff, the program once command will be allowed to execute again on that same phrase. fpviol none mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation table 31-44. erase all blocks command fccob requirements ccobix[2:0] fccob parameters 000 0x08 not required table 31-45. erase all blocks command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 000 at command launch set if command not available in current mode (see table 31-27 ) fpviol set if any area of the p-flash or eeprom memory is protected mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 1178 freescale semiconductor upon clearing ccif to launch the erase flash block command, the memory controller will erase the selected flash block and verify that it is erased. the ccif ?g will set after the erase flash block operation has completed. 31.4.6.9 erase p-flash sector command the erase p-flash sector operation will erase all addresses in a p-flash sector. upon clearing ccif to launch the erase p-flash sector command, the memory controller will erase the selected flash sector and then verify that it is erased. the ccif ?g will be set after the erase p-flash sector operation has completed. table 31-46. erase flash block command fccob requirements ccobix[2:0] fccob parameters 000 0x09 global address [17:16] to identify flash block 001 global address [15:0] in flash block to be erased table 31-47. erase flash block command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 31-27 ) set if an invalid global address [17:16] is supplied set if the supplied p-flash address is not phrase-aligned or if the eeprom address is not word-aligned fpviol set if an area of the selected flash block is protected mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation table 31-48. erase p-flash sector command fccob requirements ccobix[2:0] fccob parameters 000 0x0a global address [17:16] to identify p-flash block to be erased 001 global address [15:0] anywhere within the sector to be erased. refer to section 31.1.2.1 for the p-flash sector size.
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1179 31.4.6.10 unsecure flash command the unsecure flash command will erase the entire p-flash and eeprom memory space and, if the erase is successful, will release security. upon clearing ccif to launch the unsecure flash command, the memory controller will erase the entire p-flash and eeprom memory space and verify that it is erased. if the memory controller veri?s that the entire flash memory space was properly erased, security will be released. if the erase verify is not successful, the unsecure flash operation sets mgstat1 and terminates without changing the security state. during the execution of this command (ccif=0) the user must not write to any flash module register. the ccif ?g is set after the unsecure flash operation has completed. 31.4.6.11 verify backdoor access key command the verify backdoor access key command will only execute if it is enabled by the keyen bits in the fsec register (see table 31-10 ). the verify backdoor access key command releases security if user-supplied keys match those stored in the flash security bytes of the flash con?uration ?ld (see table 31-49. erase p-flash sector command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 31-27 ) set if an invalid global address [17:16] is supplied see table 31-3 ) set if a misaligned phrase address is supplied (global address [2:0] != 000) fpviol set if the selected p-flash sector is protected mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation table 31-50. unsecure flash command fccob requirements ccobix[2:0] fccob parameters 000 0x0b not required table 31-51. unsecure flash command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 000 at command launch set if command not available in current mode (see table 31-27 ) fpviol set if any area of the p-flash or eeprom memory is protected mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 1180 freescale semiconductor table 31-4 ). the verify backdoor access key command must not be executed from the flash block containing the backdoor comparison key to avoid code runaway. upon clearing ccif to launch the verify backdoor access key command, the memory controller will check the fsec keyen bits to verify that this command is enabled. if not enabled, the memory controller sets the accerr bit in the fstat register and terminates. if the command is enabled, the memory controller compares the key provided in fccob to the backdoor comparison key in the flash con?uration ?ld with key 0 compared to 0x3_ff00, etc. if the backdoor keys match, security will be released. if the backdoor keys do not match, security is not released and all future attempts to execute the verify backdoor access key command are aborted (set accerr) until a reset occurs. the ccif flag is set after the verify backdoor access key operation has completed. 31.4.6.12 set user margin level command the set user margin level command causes the memory controller to set the margin level for future read operations of the p-flash or eeprom block. table 31-52. verify backdoor access key command fccob requirements ccobix[2:0] fccob parameters 000 0x0c not required 001 key 0 010 key 1 011 key 2 100 key 3 table 31-53. verify backdoor access key command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 100 at command launch set if an incorrect backdoor key is supplied set if backdoor key access has not been enabled (keyen[1:0] != 10, see section 31.3.2.2 ) set if the backdoor key has mismatched since the last reset fpviol none mgstat1 none mgstat0 none table 31-54. set user margin level command fccob requirements ccobix[2:0] fccob parameters 000 0x0d flash block selection code [1:0] . see table 31-34 001 margin level setting.
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1181 upon clearing ccif to launch the set user margin level command, the memory controller will set the user margin level for the targeted block and then set the ccif ?g. note when the eeprom block is targeted, the eeprom user margin levels are applied only to the eeprom reads. however, when the p-flash block is targeted, the p-flash user margin levels are applied to both p-flash and eeprom reads. it is not possible to apply user margin levels to the p-flash block only. valid margin level settings for the set user margin level command are de?ed in table 31-55 . note user margin levels can be used to check that flash memory contents have adequate margin for normal level read operations. if unexpected results are encountered when checking flash memory contents at user margin levels, a potential loss of information has been detected. 31.4.6.13 set field margin level command the set field margin level command, valid in special modes only, causes the memory controller to set the margin level speci?d for future read operations of the p-flash or eeprom block. table 31-55. valid set user margin level settings ccob (ccobix=001) level description 0x0000 return to normal level 0x0001 user margin-1 level 1 1 read margin to the erased state 0x0002 user margin-0 level 2 2 read margin to the programmed state table 31-56. set user margin level command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch. set if command not available in current mode (see table 31-27 ). set if an invalid margin level setting is supplied. fpviol none mgstat1 none mgstat0 none
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 1182 freescale semiconductor upon clearing ccif to launch the set field margin level command, the memory controller will set the ?ld margin level for the targeted block and then set the ccif ?g. note when the eeprom block is targeted, the eeprom ?ld margin levels are applied only to the eeprom reads. however, when the p-flash block is targeted, the p-flash ?ld margin levels are applied to both p-flash and eeprom reads. it is not possible to apply ?ld margin levels to the p-flash block only. valid margin level settings for the set field margin level command are de?ed in table 31-58 . table 31-57. set field margin level command fccob requirements ccobix[2:0] fccob parameters 000 0x0e flash block selection code [1:0] . see table 31-34 001 margin level setting. table 31-58. valid set field margin level settings ccob (ccobix=001) level description 0x0000 return to normal level 0x0001 user margin-1 level 1 1 read margin to the erased state 0x0002 user margin-0 level 2 2 read margin to the programmed state 0x0003 field margin-1 level 1 0x0004 field margin-0 level 2 table 31-59. set field margin level command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch. set if command not available in current mode (see table 31-27 ). set if an invalid margin level setting is supplied. fpviol none mgstat1 none mgstat0 none
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1183 caution field margin levels must only be used during verify of the initial factory programming. note field margin levels can be used to check that flash memory contents have adequate margin for data retention at the normal level setting. if unexpected results are encountered when checking flash memory contents at ?ld margin levels, the flash memory contents should be erased and reprogrammed. 31.4.6.14 erase verify eeprom section command the erase verify eeprom section command will verify that a section of code in the eeprom is erased. the erase verify eeprom section command de?es the starting point of the data to be veri?d and the number of words. upon clearing ccif to launch the erase verify eeprom section command, the memory controller will verify the selected section of eeprom memory is erased. the ccif ?g will set after the erase verify eeprom section operation has completed. if the section is not erased, it means blank check failed, both mgstat bits will be set. table 31-60. erase verify eeprom section command fccob requirements ccobix[2:0] fccob parameters 000 0x10 global address [17:16] to identify the eeprom block 001 global address [15:0] of the ?st word to be veri?d 010 number of words to be veri?d table 31-61. erase verify eeprom section command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 010 at command launch set if command not available in current mode (see table 31-27 ) set if an invalid global address [17:0] is supplied set if a misaligned word address is supplied (global address [0] != 0) set if the requested section breaches the end of the eeprom block fpviol none mgstat1 set if any errors have been encountered during the read or if blank check failed. mgstat0 set if any non-correctable errors have been encountered during the read or if blank check failed.
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 1184 freescale semiconductor 31.4.6.15 program eeprom command the program eeprom operation programs one to four previously erased words in the eeprom block. the program eeprom operation will con?m that the targeted location(s) were successfully programmed upon completion. caution a flash word must be in the erased state before being programmed. cumulative programming of bits within a flash word is not allowed. upon clearing ccif to launch the program eeprom command, the user-supplied words will be transferred to the memory controller and be programmed if the area is unprotected. the ccobix index value at program eeprom command launch determines how many words will be programmed in the eeprom block. the ccif ?g is set when the operation has completed. 31.4.6.16 erase eeprom sector command the erase eeprom sector operation will erase all addresses in a sector of the eeprom block. table 31-62. program eeprom command fccob requirements ccobix[2:0] fccob parameters 000 0x11 global address [17:16] to identify the eeprom block 001 global address [15:0] of word to be programmed 010 word 0 program value 011 word 1 program value, if desired 100 word 2 program value, if desired 101 word 3 program value, if desired table 31-63. program eeprom command error handling register error bit error condition fstat accerr set if ccobix[2:0] < 010 at command launch set if ccobix[2:0] > 101 at command launch set if command not available in current mode (see table 31-27 ) set if an invalid global address [17:0] is supplied set if a misaligned word address is supplied (global address [0] != 0) set if the requested group of words breaches the end of the eeprom block fpviol set if the selected area of the eeprom memory is protected mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1185 upon clearing ccif to launch the erase eeprom sector command, the memory controller will erase the selected flash sector and verify that it is erased. the ccif ?g will set after the erase eeprom sector operation has completed. 31.4.7 interrupts the flash module can generate an interrupt when a flash command operation has completed or when a flash command operation has detected an ecc fault. table 31-64. erase eeprom sector command fccob requirements ccobix[2:0] fccob parameters 000 0x12 global address [17:16] to identify eeprom block 001 global address [15:0] anywhere within the sector to be erased. see section 31.1.2.2 for eeprom sector size. table 31-65. erase eeprom sector command error handling register error bit error condition fstat accerr set if ccobix[2:0] != 001 at command launch set if command not available in current mode (see table 31-27 ) set if an invalid global address [17:0] is suppliedsee table 31-3 ) set if a misaligned word address is supplied (global address [0] != 0) fpviol set if the selected area of the eeprom memory is protected mgstat1 set if any errors have been encountered during the verify operation mgstat0 set if any non-correctable errors have been encountered during the verify operation table 31-66. flash interrupt sources interrupt source interrupt flag local enable global (ccr) mask flash command complete ccif (fstat register) ccie (fcnfg register) i bit ecc double bit fault on flash read dfdif (ferstat register) dfdie (fercnfg register) i bit ecc single bit fault on flash read sfdif (ferstat register) sfdie (fercnfg register) i bit
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 1186 freescale semiconductor note vector addresses and their relative interrupt priority are determined at the mcu level. 31.4.7.1 description of flash interrupt operation the flash module uses the ccif ?g in combination with the ccie interrupt enable bit to generate the flash command interrupt request. the flash module uses the dfdif and sfdif ?gs in combination with the dfdie and sfdie interrupt enable bits to generate the flash error interrupt request. for a detailed description of the register bits involved, refer to section 31.3.2.5, ?lash configuration register (fcnfg) ? section 31.3.2.6, ?lash error configuration register (fercnfg) ? section 31.3.2.7, ?lash status register (fstat) ? and section 31.3.2.8, ?lash error status register (ferstat) ? the logic used for generating the flash module interrupts is shown in figure 31-27 . figure 31-27. flash module interrupts implementation 31.4.8 wait mode the flash module is not affected if the mcu enters wait mode. the flash module can recover the mcu from wait via the ccif interrupt (see section 31.4.7, ?nterrupts ). 31.4.9 stop mode if a flash command is active (ccif = 0) when the mcu requests stop mode, the current flash operation will be completed before the mcu is allowed to enter stop mode. flash error interrupt request ccif ccie dfdif dfdie sfdif sfdie flash command interrupt request
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1187 31.5 security the flash module provides security information to the mcu. the flash security state is de?ed by the sec bits of the fsec register (see table 31-11 ). during reset, the flash module initializes the fsec register using data read from the security byte of the flash con?uration ?ld at global address 0x3_ff0f. the security state out of reset can be permanently changed by programming the security byte assuming that the mcu is starting from a mode where the necessary p-flash erase and program commands are available and that the upper region of the p-flash is unprotected. if the flash security byte is successfully programmed, its new value will take affect after the next mcu reset. the following subsections describe these security-related subjects: unsecuring the mcu using backdoor key access unsecuring the mcu in special single chip mode using bdm mode and security effects on flash command availability 31.5.1 unsecuring the mcu using backdoor key access the mcu may be unsecured by using the backdoor key access feature which requires knowledge of the contents of the backdoor keys (four 16-bit words programmed at addresses 0x3_ff00-0x3_ff07). if the keyen[1:0] bits are in the enabled state (see section 31.3.2.2 ), the verify backdoor access key command (see section 31.4.6.11 ) allows the user to present four prospective keys for comparison to the keys stored in the flash memory via the memory controller. if the keys presented in the verify backdoor access key command match the backdoor keys stored in the flash memory, the sec bits in the fsec register (see table 31-11 ) will be changed to unsecure the mcu. key values of 0x0000 and 0xffff are not permitted as backdoor keys. while the verify backdoor access key command is active, p-flash memory and eeprom memory will not be available for read access and will return invalid data. the user code stored in the p-flash memory must have a method of receiving the backdoor keys from an external stimulus. this external stimulus would typically be through one of the on-chip serial ports. if the keyen[1:0] bits are in the enabled state (see section 31.3.2.2 ), the mcu can be unsecured by the backdoor key access sequence described below: 1. follow the command sequence for the verify backdoor access key command as explained in section 31.4.6.11 2. if the verify backdoor access key command is successful, the mcu is unsecured and the sec[1:0] bits in the fsec register are forced to the unsecure state of 10 the verify backdoor access key command is monitored by the memory controller and an illegal key will prohibit future use of the verify backdoor access key command. a reset of the mcu is the only method to re-enable the verify backdoor access key command. the security as de?ed in the flash security byte (0x3_ff0f) is not changed by using the verify backdoor access key command sequence. the backdoor keys stored in addresses 0x3_ff00-0x3_ff07 are unaffected by the verify backdoor access key command sequence. the verify backdoor access key command sequence has no effect on the program and erase protections de?ed in the flash protection register, fprot. after the backdoor keys have been correctly matched, the mcu will be unsecured. after the mcu is unsecured, the sector containing the flash security byte can be erased and the flash security byte can be
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 1188 freescale semiconductor reprogrammed to the unsecure state, if desired. in the unsecure state, the user has full control of the contents of the backdoor keys by programming addresses 0x3_ff00-0x3_ff07 in the flash con?uration ?ld. 31.5.2 unsecuring the mcu in special single chip mode using bdm a secured mcu can be unsecured in special single chip mode by using the following method to erase the p-flash and eeprom memory: 1. reset the mcu into special single chip mode 2. delay while the bdm executes the erase verify all blocks command write sequence to check if the p-flash and eeprom memories are erased 3. send bdm commands to disable protection in the p-flash and eeprom memory 4. execute the erase all blocks command write sequence to erase the p-flash and eeprom memory. alternatively the unsecure flash command can be executed, if so the steps 5 and 6 below are skeeped. 5. after the ccif ?g sets to indicate that the erase all blocks operation has completed, reset the mcu into special single chip mode 6. delay while the bdm executes the erase verify all blocks command write sequence to verify that the p-flash and eeprom memory are erased if the p-flash and eeprom memory are veri?d as erased, the mcu will be unsecured. all bdm commands will now be enabled and the flash security byte may be programmed to the unsecure state by continuing with the following steps: 7. send bdm commands to execute the program p-flash command write sequence to program the flash security byte to the unsecured state 8. reset the mcu 31.5.3 mode and security effects on flash command availability the availability of flash module commands depends on the mcu operating mode and security state as shown in table 31-27 . 31.6 initialization on each system reset the ?sh module executes an initialization sequence which establishes initial values for the flash block con?uration parameters, the fprot and eeprot protection registers, and the fopt and fsec registers. the initialization routine reverts to built-in default values that leave the module in a fully protected and secured state if errors are encountered during execution of the reset sequence. if a double bit fault is detected during the reset sequence, both mgstat bits in the fstat register will be set. ccif is cleared throughout the initialization sequence. the flash module holds off all cpu access for a portion of the initialization sequence. flash reads are allowed once the hold is removed. completion of the initialization sequence is marked by setting ccif high which enables user commands.
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 freescale semiconductor 1189 if a reset occurs while any flash command is in progress, that command will be immediately aborted. the state of the word being programmed or the sector/block being erased is not guaranteed.
240 kbyte flash module (s12ftmrg240k2v1) mc9s12g family reference manual, rev.1.23 1190 freescale semiconductor
mc9s12g family reference manual, rev.1.23 freescale semiconductor 1191 appendix a electrical characteristics revision history version number revision date description of changes rev 0.37 24-apr-2012 added figure a-2 rev 0.38 16-aug-2012 updated table a-18 (num 1 12) updated table a-43 (num 9) corrected section a.3.1, ?easurement conditions rev 0.39 13-sep-2012 added section a.4.2.1, ?ifferential reference voltage updated table a-43 (num 9) rev 0.40 14-sep-2012 updated table a-43 (num 9) updated table a-19 (num 5,6) rev 0.41 26-oct-2012 added table a-10 updated table a-21 (test conditions) updated table a-24 (test conditions) updated table a-26 (test conditions) updated table a-28 (test conditions) rev 0.42 2-nov-2012 updated table a-33 (num 1) rev 0.43 22-nov-2012 updated table a-4 (temperature option w) added table a-7 added table a-9 updated table a-17 (num 4, 8) updated table a-18 (num 4) added table a-22 added table a-24 added table a-26 added table a-28 added table a-32 rev 0.44 2-dec-2012 updated table a-1 (num 1) updated table a-4 (added paramerer t jmax ) updated table a-7 (num 6, conditions) updated table a-9 (num 6, conditions) updated table a-10 (conditions) added table a-16 updated table a-17 (num 8) updated table a-19 (conditions) updated table a-20 (conditions) updated table a-22 (all rows, conditions) updated table a-24 (all rows, conditions) updated table a-26 (all rows, conditions) updated table a-32 (conditions) updated table a-33 (conditions) updated table a-46 (conditions) updated table a-47 (conditions) updated table a-48 (conditions)
electrical characteristics mc9s12g family reference manual, rev.1.23 1192 freescale semiconductor a.1 general this supplement contains the most accurate electrical information for the mc9s12g microcontroller available at the time of publication. this introduction is intended to give an overview on several common topics like power supply, current injection etc. a.1.1 parameter classi?ation the electrical parameters shown in this supplement are guaranteed by various methods. to give the customer a better understanding the following classi?ation is used and the parameters are tagged accordingly in the tables where appropriate. note this classi?ation is shown in the column labeled ??in the parameter tables where appropriate. p: those parameters are guaranteed during production testing on each individual device. c: those parameters are achieved by the design characterization by measuring a statistically relevant sample size across process variations. t: those parameters are achieved by design characterization on a small sample size from typical devices under typical conditions unless otherwise noted. all values shown in the typical column are within this category. d: those parameters are derived mainly from simulations. a.1.2 power supply the vdda, vssa pin pairs supply the a/d converter and parts of the internal voltage regulator. the vddx, vssx pin pairs [3:1] supply the i/o pins. vddr supplies the internal voltage regulator. rev 0.45 9-jan-2013 updated table a-1 (num 9, 10) updated table a-4 (removed paramerer t jmax ) added table a-11 updated table a-16 (num 1-3) updated table a-17 (num 4) updated table a-18 (num 1) added table a-41 updated table a-44 (all rows, conditions) rev 0.46 24-jan-2013 updated table a-16 (num 1-3) updated table a-17 (num 4, 8) added table a-44 (num 1-3) rev 0.47 25-jan-2013 updated table a-29 (num 5, 6) added table a-38 version number revision date description of changes
electrical characteristics mc9s12g family reference manual, rev.1.23 freescale semiconductor 1193 the vddf, vss1 pin pair supplies the internal nvm logic. all vddx pins are internally connected by metal. all vssx pins are internally connected by metal. vdda, vddx and vssa, vssx are connected by diodes for esd protection. note in the following context v dd35 is used for either vdda, vddr, and vddx; v ss35 is used for either vssa and vssx unless otherwise noted. i dd35 denotes the sum of the currents ?wing into the vdda, vddx and vddr pins. a.1.3 pins there are four groups of functional pins. a.1.3.1 i/o pins the i/o pins have a level in the range of 3.13v to 5.5v. this class of pins is comprised of all port i/o pins, the analog inputs, bkgd and the reset pins. some functionality may be disabled. a.1.3.2 analog reference this group consists of the vrh pin. a.1.3.3 oscillator the pins extal, xtal dedicated to the oscillator have a nominal 1.8v level. a.1.3.4 test this pin is used for production testing only. the test pin must be tied to ground in all applications. a.1.4 current injection power supply must maintain regulation within operating v dd35 or v dd range during instantaneous and operating maximum current conditions. if positive injection current (v in > v dd35 ) is greater than i dd35 , the injection current may ?w out of v dd35 and could result in external power supply going out of regulation. ensure external v dd35 load will shunt current greater than maximum injection current. this will be the greatest risk when the mcu is not consuming power; e.g., if no system clock is present, or if clock rate is very low which would reduce overall power consumption.
electrical characteristics mc9s12g family reference manual, rev.1.23 1194 freescale semiconductor a.1.5 absolute maximum ratings absolute maximum ratings are stress ratings only. a functional operation under or outside those maxima is not guaranteed. stress beyond those limits may affect the reliability or cause permanent damage of the device. this device contains circuitry protecting against damage due to high static voltage or electrical ?lds; however, it is advised that normal precautions be taken to avoid application of any voltages higher than maximum-rated voltages to this high-impedance circuit. reliability of operation is enhanced if unused inputs are tied to an appropriate logic voltage level (e.g., either v ss35 or v dd35 ). a.1.6 esd protection and latch-up immunity all esd testing is in conformity with cdf-aec-q100 stress test quali?ation for automotive grade integrated circuits. during the device quali?ation esd stresses were performed for the human body model (hbm) and the charge device model. a device will be de?ed as a failure if after exposure to esd pulses the device no longer meets the device speci?ation. complete dc parametric and functional testing is performed per the applicable device speci?ation at room temperature followed by hot temperature, unless speci?d otherwise in the device speci?ation. table a-1. absolute maximum ratings 1 1 beyond absolute maximum ratings device might be damaged. num rating symbol min max unit 1 i/o, regulator and analog supply voltage v dd35 ?.3 6.0 v 2 voltage difference v ddx to v dda ? vddx ?.0 0.3 v 3 voltage difference v ssx to v ssa ? vssx ?.3 0.3 v 4 digital i/o input voltage v in ?.3 6.0 v 5 analog reference v rh ?.3 6.0 v 6 extal, xtal v ilv ?.3 2.16 v 7 instantaneous maximum current single pin limit for all digital i/o pins 2 2 all digital i/o pins are internally clamped to v ssx and v ddx , or v ssa and v dda . i d ?5 +25 ma 8 instantaneous maximum current single pin limit for extal, xtal i dl ?5 +25 ma 9 maximum current single pin limit for power supply pins i dv ?0 +60 ma 10 storage temperature range ( m , v , c , and w temperature range) t stg ?5 155 c
electrical characteristics mc9s12g family reference manual, rev.1.23 freescale semiconductor 1195 a.1.7 operating conditions this section describes the operating conditions of the device. unless otherwise noted those conditions apply to all the following data. note please refer to the temperature rating of the device (c, v, m, w) with regards to the ambient temperature t a and the junction temperature t j .for power dissipation calculations refer to section a.1.8, ?ower dissipation and thermal characteristics . table a-2. esd and latch-up test conditions model description symbol value unit human body series resistance r1 1500 ? storage capacitance c 100 pf number of pulse per pin positive negative - - 3 3 table a-3. esd and latch-up protection characteristics num c rating symbol min max unit 1c human body model (hbm) v hbm 2000 - v 2c charge device model (cdm) v cdm 500 - v 3c charge device model (cdm) (corner pins) v cdm 750 - v table a-4. operating conditions rating symbol min typ max unit i/o, regulator and analog supply voltage v dd35 3.13 5 5.5 v oscillator f osc 4 16 mhz bus frequency f bus 0.5 25 mhz temperature option c operating ambient temperature range 1 operating junction temperature range t a t j ?0 ?0 27 85 105 c temperature option v operating ambient temperature range 1 operating junction temperature range t a t j ?0 ?0 27 105 105 c temperature option m operating ambient temperature range 1 operating junction temperature range t a t j ?0 ?0 27 125 150 c temperature option w operating ambient temperature range 1 operating junction temperature range t a t j ?0 ?0 27 150 160 c
electrical characteristics mc9s12g family reference manual, rev.1.23 1196 freescale semiconductor note operation is guaranteed when powering down until low voltage reset assertion. 1 please refer to section a.1.8, ?ower dissipation and thermal characteristics for more details about the relation between ambient temperature t a and device junction temperature t j .
electrical characteristics mc9s12g family reference manual, rev.1.23 freescale semiconductor 1197 a.1.8 power dissipation and thermal characteristics power dissipation and thermal characteristics are closely related. the user must assure that the maximum operating junction temperature is not exceeded. the average chip-junction temperature (t j ) in c can be obtained from: the total power dissipation can be calculated from: p io is the sum of all output currents on i/o ports associated with v ddx , whereby t j t a p d ja ? () + = t j junction temperature, [ c ] = t a ambient temperature, [ c ] = p d total chip power dissipation, [w] = ja package thermal resistance, [ c/w] = p d p int p io + = p int chip internal power dissipation, [w] = p io r dson i i io i 2 ? = r dson v ol i ol ------------ for outputs driven low ; = r dson v dd35 v oh i oh --------------------------------------- for outputs driven high ; = p int i ddr v ddr ? i dda v dda ? + =
electrical characteristics mc9s12g family reference manual, rev.1.23 1198 freescale semiconductor
electrical characteristics mc9s12g family reference manual, rev.1.23 freescale semiconductor 1199 table a-5. thermal package characteristics 1 num c rating symbol s12gn32, s12gna32, s12gn16, s12gna16 s12g64, s12ga64, s12g48, s12gn48, s12ga64 s12g128, s12ga128, s12g96, s12ga96 s12g240, s12ga240, s12g192, s12ga192 unit 20-pin tssop 1d thermal resistance single sided pcb, natural convection 2 ja 91 c/w 2d thermal resistance single sided pcb @ 200 ft/min 3 jma 72 c/w 3d thermal resistance double sided pcb with 2 internal planes, natural convection 3 ja 58 c/w 4d thermal resistance double sided pcb with 2 internal planes @ 200 ft/min 3 jma 51 c/w 5 d junction to board 4 jb 29 c/w 6 d junction to case 5 jc 20 c/w 7 d junction to package top 6 jt 4 c/w 32-pin lqfp 8d thermal resistance single sided pcb, natural convection 2 ja 81 84 c/w 9d thermal resistance single sided pcb @ 200 ft/min 3 jma 68 70 c/w 10 d thermal resistance double sided pcb with 2 internal planes, natural convection 3 ja 57 56 c/w 11 d thermal resistance double sided pcb with 2 internal planes @ 200 ft/min 3 jma 50 49 c/w 12 d junction to board 4 jb 35 32 c/w 13 d junction to case 5 jc 25 23 c/w 14 d junction to package top 6 jt 86 c/w 48-pin lqfp 15 d thermal resistance single sided pcb, natural convection 2 ja 81 80 79 75 c/w 16 d thermal resistance single sided pcb @ 200 ft/min 3 jma 68 67 66 62 c/w 17 d thermal resistance double sided pcb with 2 internal planes, natural convection 3 ja 57 56 56 51 c/w 18 d thermal resistance double sided pcb with 2 internal planes @ 200 ft/min 3 jma 50 50 49 45 c/w 19 d junction to board 4 jb 35 34 33 30 c/w 20 d junction to case 5 jc 25 24 21 19 c/w 21 d junction to package top 6 jt 8 6 4 n/a c/w
electrical characteristics mc9s12g family reference manual, rev.1.23 1200 freescale semiconductor 48-pin qfn 22 d thermal resistance single sided pcb, natural convection 2 ja 82 c/w 23 d thermal resistance single sided pcb @ 200 ft/min 3 jma 67 c/w 24 d thermal resistance double sided pcb with 2 internal planes, natural convection 3 ja 28 c/w 25 d thermal resistance double sided pcb with 2 internal planes @ 200 ft/min 3 jma 23 c/w 26 d junction to board 4 jb 11 c/w 27 d junction to case 5 jc n/a c/w 28 d junction to package top 6 jt 4 c/w 64-pin lqfp 29 d thermal resistance single sided pcb, natural convection 2 ja 70 70 70 c/w 30 d thermal resistance single sided pcb @ 200 ft/min 3 jma 59 58 58 c/w 31 d thermal resistance double sided pcb with 2 internal planes, natural convection 3 ja 52 52 52 c/w 32 d thermal resistance double sided pcb with 2 internal planes @ 200 ft/min 3 jma 46 46 45 c/w 33 d junction to board 4 jb 34 34 35 c/w 34 d junction to case 5 jc 20 18 17 c/w 35 d junction to package top 6 jt 5 4 n/a c/w 100-pin lqfp 36 d thermal resistance single sided pcb, natural convection 2 ja 61 62 c/w 37 d thermal resistance single sided pcb @ 200 ft/min 3 jma 51 55 c/w 38 d thermal resistance double sided pcb with 2 internal planes, natural convection 3 ja 49 51 c/w 39 d thermal resistance double sided pcb with 2 internal planes @ 200 ft/min 3 jma 43 47 c/w 40 d junction to board 4 jb 34 37 c/w 41 d junction to case 5 jc 16 17 c/w 42 d junction to package top 6 jt 3 n/a c/w table a-5. thermal package characteristics 1 num c rating symbol s12gn32, s12gna32, s12gn16, s12gna16 s12g64, s12ga64, s12g48, s12gn48, s12ga64 s12g128, s12ga128, s12g96, s12ga96 s12g240, s12ga240, s12g192, s12ga192 unit
electrical characteristics mc9s12g family reference manual, rev.1.23 freescale semiconductor 1201 a.2 i/o characteristics this section describes the characteristics of all i/o pins except extal, xtal, test, and supply pins. 1 the values for thermal resistance are achieved by package simulations 2 per jedec jesd51-2 with the single layer board (jesd51-3) horizontal.j 3 per jedec jesd51-6 with the board (jesd51-7) horizontal. 4 .thermal resistance between the die and the printed circuit board per jedec jesd51-8. board temperature is measured in simulation on the top surface of the board near the package. 5 thermal resistance between the die and the case top surface as measured in simulation by the cold plate method (mil spec-883 method 1012.1). 6 thermal characterization parameter indicating the temperature difference between package top and the junction temperature per jedec jesd51-2. jt is a useful value to use to estimate junction temperature in a steady state customer enviroment. table a-6. 3.3-v i/o characteristics (junction temperature from ?0 c to +150 c) conditions are 3.15 v < v dd35 < 3.6 v junction temperature from ?0 c to +150 c, unless otherwise noted i/o characteristics for all i/o pins except extal, xtal,test and supply pins. num c rating symbol min typ max unit 1 p input high voltage v ih 0.65*v dd35 v 2 t input high voltage v ih v dd35 +0.3 v 3 p input low voltage v il 0.35*v dd35 v 4 t input low voltage v il v ss35 ?0.3 v 5 c input hysteresis v hys 0.06*v dd35 0.3*v dd35 mv 6 p input leakage current (pins in high impedance input mode) 1 v in = v dd35 or v ss35 +125 c to < t j < 150 c +105 c to < t j < 125 ?0 c to < t j < 105 c 1 maximum leakage current occurs at maximum operating temperature. current decreases by approximately one-half for each 8 c to 12 c in the temperature range from 50 c to 125 c. i in -1 -0.5 -0.4 1 0.5 0.4 a 7 p output high voltage (pins in output mode) i oh = ?.75 ma v oh v dd35 -0.4 v 8 c output low voltage (pins in output mode) i ol = +1.75 ma v ol 0.4 v 9 p internal pull up device current v ih min > input voltage > v il max i pul -1 ?0 a 10 p internal pull down device current v ih min > input voltage > v il max i pdh 1 70 a 11 d input capacitance c in ?pf 12 t injection current 2 single pin limit total device limit, sum of all injected currents 2 refer to section a.1.4, ?urrent injection for more details i ics i icp ?.5 ?5 2.5 25 ma
electrical characteristics mc9s12g family reference manual, rev.1.23 1202 freescale semiconductor table a-7. 3.3-v i/o characteristics (junction temperature from +150 c to +160 c) conditions are 3.15 v < v dd35 < 3.6 v junction temperature from +150 c to +160 c, unless otherwise noted i/o characteristics for all i/o pins except extal, xtal,test and supply pins. num c rating symbol min typ max unit 1 c input high voltage v ih 0.65*v dd35 v 2 t input high voltage v ih v dd35 +0.3 v 3 c input low voltage v il 0.35*v dd35 v 4 t input low voltage v il v ss35 ?0.3 v 5 c input hysteresis v hys 0.06*v dd35 0.3*v dd35 mv 6 c input leakage current (pins in high impedance input mode) 1 v in = v dd35 or v ss35 1 maximum leakage current occurs at maximum operating temperature. current decreases by approximately one-half for each 8 c to 12 c in the temperature range from 50 c to 125 c. i in -1 1 a 7 c output high voltage (pins in output mode) i oh = ?.75 ma v oh v dd35 -0.4 v 8 c output low voltage (pins in output mode) i ol = +1.75 ma v ol 0.4 v 9 c internal pull up device current v ih min > input voltage > v il max i pul -1 ?0 a 10 c internal pull down device current v ih min > input voltage > v il max i pdh 1 70 a 11 d input capacitance c in ?pf 12 t injection current 2 single pin limit total device limit, sum of all injected currents 2 refer to section a.1.4, ?urrent injection for more details i ics i icp ?.5 ?5 2.5 25 ma
electrical characteristics mc9s12g family reference manual, rev.1.23 freescale semiconductor 1203 table a-8. 5-v i/o characteristics (junction temperature from ?0 c to +150 c) conditions are 4.5 v < v dd35 < 5.5 v junction temperature from ?0 c to +150 c, unless otherwise noted i/o characteristics for all i/o pins except extal, xtal,test and supply pins. num c rating symbol min typ max unit 1 p input high voltage v ih 0.65*v dd35 v 2 t input high voltage v ih v dd35 +0.3 v 3 p input low voltage v il 0.35*v dd35 v 4 t input low voltage v il v ssrx ?.3 v 5 c input hysteresis v hys 0.06*v dd35 0.3*v dd35 mv 6 p input leakage current (pins in high impedance input mode) 1 v in = v dd35 or v ss35 +125 c to < t j < 150 c +105 c to < t j < 125 ?0 c to < t j < 105 c 1 maximum leakage current occurs at maximum operating temperature. current decreases by approximately one-half for each 8 c to 12 c in the temperature range from 50 c to 125 c. i in -1 -0.5 -0.4 1 0.5 0.4 a 7 p output high voltage (pins in output mode) i oh = ? ma v oh v dd35 ?0.8 v 8 p output low voltage (pins in output mode) i ol = +4ma v ol 0.8 v 9 p internal pull up current v ih min > input voltage > v il max i pul -10 -130 a 10 p internal pull down current v ih min > input voltage > v il max i pdh 10 130 a 11 d input capacitance c in ?pf 12 t injection current 2 single pin limit total device limit, sum of all injected currents 2 refer to section a.1.4, ?urrent injection for more details i ics i icp ?.5 ?5 2.5 25 ma
electrical characteristics mc9s12g family reference manual, rev.1.23 1204 freescale semiconductor table a-9. 5-v i/o characteristics (junction temperature from +150 c to +160 c) conditions are 4.5 v < v dd35 < 5.5 v junction temperature from +150 c to +160 c, unless otherwise noted i/o characteristics for all i/o pins except extal, xtal,test and supply pins. num c rating symbol min typ max unit 1 c input high voltage v ih 0.65*v dd35 v 2 t input high voltage v ih v dd35 +0.3 v 3 c input low voltage v il 0.35*v dd35 v 4 t input low voltage v il v ssrx ?.3 v 5 c input hysteresis v hys 0.06*v dd35 0.3*v dd35 mv 6 c input leakage current (pins in high impedance input mode) 1 v in = v dd35 or v ss35 1 maximum leakage current occurs at maximum operating temperature. current decreases by approximately one-half for each 8 c to 12 c in the temperature range from 50 c to 125 c. i in -1 1 a 7 c output high voltage (pins in output mode) i oh = ? ma v oh v dd35 ?0.8 v 8 c output low voltage (pins in output mode) i ol = +4ma v ol 0.8 v 9 c internal pull up current v ih min > input voltage > v il max i pul -10 -130 a 10 c internal pull down current v ih min > input voltage > v il max i pdh 10 130 a 11 d input capacitance c in ?pf 12 t injection current 2 single pin limit total device limit, sum of all injected currents 2 refer to section a.1.4, ?urrent injection for more details i ics i icp ?.5 ?5 2.5 25 ma table a-10. pin interrupt characteristics (junction temperature from ?0 c to +150 c) conditions are 3.13v < v dd35 < 5.5 v unless otherwise noted. num c rating symbol min typ max unit 1 p port j, p, ad interrupt input pulse ?tered (stop) 1 1 parameter only applies in stop or pseudo stop mode. t p_mask 3 s 2 p port j, p, ad interrupt input pulse passed (stop) 1 t p_pass 10 s 3 d port j, p, ad interrupt input pulse ?tered ( st op) in number of bus clock cycles of period 1/f bus n p_mask 3 4 d port j, p, ad interrupt input pulse passed ( st op) in number of bus clock cycles of period 1/f bus n p_pass 4 5d irq pulse width, edge-sensitive mode ( st op) in number of bus clock cycles of period 1/f bus n irq 1
electrical characteristics mc9s12g family reference manual, rev.1.23 freescale semiconductor 1205 a.3 supply currents this section describes the current consumption characteristics of the device as well as the conditions for the measurements. a.3.1 measurement conditions run current is measured on the vddx, vddr 1 , and vdda 2 pins. it does not include the current to drive external loads. unless otherwise noted the currents are measured in special single chip mode and the cpu code is executed from ram. for run and wait current measurements pll is on and the reference clock is the irc1m trimmed to 1mhz. the bus frequency is 25mhz and the cpu frequency is 50mhz. table a-12., table a-13. and table a-14. show the con?uration of the cpmu module and the peripherals for run, wait and stop current measurement. table a-11. pin interrupt characteristics (junction temperature from +150 c to +160 c) conditions are 3.13v < v dd35 < 5.5 v unless otherwise noted. num c rating symbol min typ max unit 1 c port j, p, ad interrupt input pulse ?tered (stop) 1 1 parameter only applies in stop or pseudo stop mode. t p_mask 3 s 2 c port j, p, ad interrupt input pulse passed (stop) 1 t p_pass 10 s 3 d port j, p, ad interrupt input pulse ?tered ( st op) in number of bus clock cycles of period 1/f bus n p_mask 3 4 d port j, p, ad interrupt input pulse passed ( st op) in number of bus clock cycles of period 1/f bus n p_pass 4 5d irq pulse width, edge-sensitive mode ( st op) in number of bus clock cycles of period 1/f bus n irq 1 1. on some packages vddr is bonded to vddx and the pin is named vddxr. refer to section 1.8, ?evice pinouts for further details. 2. on some packages vdda is connected with vddxr and the common pin is named vddxra.on some packages vssa is connected to vssx and the common pin is named vssxa. see section section 1.8, ?evice pinouts for further details. table a-12. cpmu con?uration for pseudo stop current measurement cpmu register bit settings/conditions cpmuclks pllsel=0, pstp=1, pre=pce=rtioscsel=coposcsel=1 cpmuosc osce=1, external square wave on extal f extal =4mhz, v ih = 1.8v, v il =0v
electrical characteristics mc9s12g family reference manual, rev.1.23 1206 freescale semiconductor cpmurti rtdec=0, rtr[6:4]=111, rtr[3:0]=1111; cpmucop wcop=1, cr[2:0]=111 table a-13. cpmu con?uration for run/wait and full stop current measurement cpmu register bit settings/conditions cpmusynr vcofrq[1:0]=01,syndiv[5:0] = 24 cpmupostdiv postdiv[4:0]=0 cpmuclks pllsel=1 cpmuosc osce=0, reference clock for pll is f ref =f irc1m trimmed to 1mhz api settings for stop current measurement cpmuapictl apiea=0, apife=1, apie=0 cpmuapitr trimmed to 10khz cpmuapirh/rl set to $ffff table a-14. peripheral con?urations for run & wait current measurement peripheral configuration mscan con?ured to loop-back mode using a bit rate of 1mbit/s spi con?ured to master mode, continuously transmit data (0x55 or 0xaa) at 1mbit/s sci con?ured into loop mode, continuously transmit data (0x55) at speed of 57600 baud pwm con?ured to toggle its pins at the rate of 40khz adc the peripheral is con?ured to operate at its maximum speci?d frequency and to continuously convert voltages on all input channels in sequence. dbg the module is enabled and the comparators are con?ured to trigger in outside range.the range covers all the code executed by the core. table a-12. cpmu con?uration for pseudo stop current measurement cpmu register bit settings/conditions
electrical characteristics mc9s12g family reference manual, rev.1.23 freescale semiconductor 1207 table a-15. run and wait current characteristics (junction temperature from ?0 c to +150 c) tim the peripheral shall be con?ured to output compare mode, pulse accumulator and modulus counter enabled. cop & rti both modules are enabled. acmp 1 the module is enabled with analog output on. the acmpp and acmpm are toggling with 0-1 and 1-0. dac 2 dac0 and dac1 is buffered at full voltage range (dacxctl = $87). rva 3 the module is enabled and adc is running at 6.25mhz with maximum bus freq 1 onlly available on s12gn16, s12gn32, s12gn48, s12g48, and s12g64 2 only available on s12g192, s12ga192, s12g340, and s12ga240 3 only available on s12ga192 and s12ga240 conditions are: v ddr =5.5v, t a =125 c, see table a-13. and table a-14. num c rating symbol min typ max unit s12gn16, s12gn32 1 p idd run current (code execution from ram) i ddrr 12.5 16 ma 2 c idd run current (code execution from ?sh) i ddrf 13 17 ma 3 p idd wait current i ddw 7.2 10 ma s12gn48, s12g48, s12g64 4 p idd run current (code execution from ram) i ddrr 14 19 ma 5 c idd run current (code execution from ?sh) i ddrf 15.5 20 ma 6 p idd wait current i ddw 8.7 11 ma s12g96, s12g128 7 p idd run current (code execution from ram) i ddrr 15 21 ma 8 c idd run current (code execution from ?sh) i ddrf 17 22 ma 9 p idd wait current i ddw 9 11.5 ma s12g192, s12ga192, s12g240, s12ga240 10 p idd run current (code execution from ram) i ddrr 18 22.5 ma 11 c idd run current (code execution from ?sh) i ddrf 17 23.5 ma 12 p idd wait current i ddw 9.5 12 ma table a-14. peripheral con?urations for run & wait current measurement peripheral configuration
electrical characteristics mc9s12g family reference manual, rev.1.23 1208 freescale semiconductor table a-16. run and wait current characteristics (junction temperature from +150 c to +160 c) conditions are: v ddr =5.5v, t a =150 c, see table a-13. and table a-14. num c rating symbol min typ max unit s12gn16, s12gn32 1 c idd run current (code execution from ram) i ddrr 12.7 ma 2 c idd run current (code execution from ?sh) i ddrf 13.2 ma 3 c idd wait current i ddw 7.4 ma
electrical characteristics mc9s12g family reference manual, rev.1.23 freescale semiconductor 1209 table a-17. full stop current characteristics conditions are: typ: v ddx ,v ddr ,v dda =5v, max: v ddx ,v ddr ,v dda =5.5v api see table a-13. num c rating symbol min typ max unit s12gn16, s12gn32 stop current api disabled 1 p -40 ci dds 14.4 24 a 2p25 ci dds 16.5 28 a 3 p 150 ci dds 120 320 a 4 c 160 ci dds 140 a stop current api enabled 5 c -40 ci dds 18.5 a 6c25 ci dds 21.5 a 7 c 150 ci dds 130 a 8 c 160 ci dds 150 a s12gn48, s12g48, s12g64 stop current api disabled 9 p -40 ci dds 16 27 a 10 p 25 ci dds 18.5 30 a 11 p 150 ci dds 140 370 a stop current api enabled 12 c -40 ci dds 20 a 13 c 25 ci dds 23.5 a 14 c 150 ci dds 150 a s12g96, s12g128 stop current api disabled 15 p -40 ci dds 16.5 28 a 16 p 25 ci dds 19 32 a 17 p 150 ci dds 150 400 a stop current api enabled 18 c -40 ci dds 20.5 a 19 c 25 ci dds 24 a 20 c 150 ci dds 160 a s12g192, s12ga192, s12g240, s12ga240 stop current api disabled 21 p -40 ci dds 17 30 a 22 p 25 ci dds 19.5 34 a 23 p 150 ci dds 155 420 a stop current api enabled 24 c -40 ci dds 21 a 25 c 25 ci dds 24.5 a 26 c 150 ci dds 160 a
electrical characteristics mc9s12g family reference manual, rev.1.23 1210 freescale semiconductor table a-18. pseudo stop current characteristics a.4 adc characteristics this section describes the characteristics of the analog-to-digital converter. a.4.1 adc operating characteristics the table a-19 and table a-20 show conditions under which the adc operates. the following constraints exist to obtain full-scale, full range results: v ssa v rl v in v rh v dda . conditions are: v ddx =5v, v ddr =5v, v dda =5v, rti and cop and api enabled, see table a-12. num c rating symbol min typ max unit s12gn16, s12gn32 1 c -40 ci ddps 155 a 2c25 ci ddps 165 a 3 c 150 ci ddps 265 a 4 c 160 ci ddps 295 a s12gn48, s12g48, s12g64 5 c -40 ci ddps 160 a 6c25 ci ddps 170 a 7 c 150 ci ddps 285 a s12g96, s12g128 8 c -40 ci ddps 165 a 9c25 ci ddps 175 a 10 c 150 ci ddps 320 a s12g192, s12ga192, s12g240, s12ga240 11 c -40 ci ddps 175 a 12 c 25 ci ddps 185 a 13 c 150 ci ddps 430 a
electrical characteristics mc9s12g family reference manual, rev.1.23 freescale semiconductor 1211 this constraint exists since the sample buffer ampli?r can not drive beyond the power supply levels that it ties to. if the input level goes outside of this range it will effectively be clipped. table a-19. adc operating characteristics a.4.2 factors in?encing accuracy source resistance, source capacitance and current injection have an in?ence on the accuracy of the adc. a further factor is that port ad pins that are con?ured as output drivers switching. a.4.2.1 differential reference voltage the accuracy is reduced if the differential reference voltage is less than 3.13v when using the atd in the 3.3v range or if the differential reference voltage is less than 4.5v when using the atd in the 5v range. a.4.2.2 port ad output drivers switching port ad output drivers switching can adversely affect the adc accuracy whilst converting the analog voltage on other port ad pins because the output drivers are supplied from the vdda/vssa adc supply pins. although internal design measures are implemented to minimize the affect of output driver noise, it is recommended to con?ure port ad pins as outputs only for low frequency, low load outputs. the impact on adc accuracy is load dependent and not speci?d. the values speci?d are valid under condition that no port ad output drivers switch during conversion. a.4.2.3 source resistance due to the input pin leakage current as speci?d in conjunction with the source resistance there will be a voltage drop from the signal source to the adc input. the maximum source resistance r s speci?s results supply voltage 3.13 v < v dda < 5.5 v, -40 o c < t j < t jmax 1 1 see table a-4 num c rating symbol min typ max unit 1 d reference potential low high v rl v rh v ssa v dda /2 v dda /2 v dda v v 2 d voltage difference v ddx to v dda ? vddx ?.35 0 0.1 v 3 d voltage difference v ssx to v ssa ? vssx ?.1 0 0.1 v 4 c differential reference voltage v rh -v rl 3.13 5.0 5.5 v 5 c adc clock frequency (derived from bus clock via the prescaler bus) f atdclk 0.25 8.0 mhz 8d adc conversion period 2 12 bit resolution: 10 bit resolution: 8 bit resolution: 2 the minimum time assumes a sample time of 4 adc clock cycles. the maximum time assumes a sample time of 24 adc clock cycles and the discharge feature (smp_dis) enabled, which adds 2 adc clock cycles. n conv12 n conv10 n conv8 20 19 17 42 41 39 adc clock cycles
electrical characteristics mc9s12g family reference manual, rev.1.23 1212 freescale semiconductor in an error (10-bit resolution) of less than 1/2 lsb (2.5 mv) at the maximum leakage current. if device or operating conditions are less than worst case or leakage-induced error is acceptable, larger values of source resistance of up to 10kohm are allowed. a.4.2.4 source capacitance when sampling an additional internal capacitor is switched to the input. this can cause a voltage drop due to charge sharing with the external and the pin capacitance. for a maximum sampling error of the input voltage 1lsb (10-bit resilution), then the external ?ter capacitor, c f 1024 * (c ins ? inn ). a.4.2.5 current injection there are two cases to consider. 1. a current is injected into the channel being converted. the channel being stressed has conversion values of $3ff (in 10-bit mode) for analog inputs greater than v rh and $000 for values less than v rl unless the current is higher than speci?d as disruptive condition. 2. current is injected into pins in the neighborhood of the channel being converted. a portion of this current is picked up by the channel (coupling ratio k), this additional current impacts the accuracy of the conversion depending on the source resistance. the additional input voltage error on the converted channel can be calculated as: v err = k * r s * i inj with i inj being the sum of the currents injected into the two pins adjacent to the converted channel. a.4.3 adc accuracy table a-21 and table a-26 specifies the adc conversion performance excluding any errors due to current injection, input capacitance and source resistance. table a-20. adc electrical characteristics supply voltage 3.13 v < v dda < 5.5 v, -40 o c < t j < t jmax 1 1 see table a-4 num c rating symbol min typ max unit 1 c max input source resistance 2 2 1 refer to a.4.2.3 for further information concerning source resistance r s 1k ? 2 d total input capacitance non sampling total input capacitance sampling c inn c ins 10 16 pf 3 d input internal resistance r ina - 5 15 k ? 4 c disruptive analog input current i na -2.5 2.5 ma 5 c coupling ratio positive current injection k p 1e-4 a/a 6 c coupling ratio negative current injection k n 5e-3 a/a
electrical characteristics mc9s12g family reference manual, rev.1.23 freescale semiconductor 1213 a.4.3.1 adc accuracy de?itions for the following de?itions see also figure a-1 . differential non-linearity (dnl) is de?ed as the difference between two adjacent switching steps. the integral non-linearity (inl) is de?ed as the sum of all dnls: dnl i () v i v i1 1lsb ------------------------- - 1 = inl n () dnl i () i1 = n v n v 0 1lsb -------------------- - n ==
electrical characteristics mc9s12g family reference manual, rev.1.23 1214 freescale semiconductor figure a-1. adc accuracy de?itions note figure a-1 shows only de?itions, for speci?ation values refer to table a-21 and table a-26 . 1 5 vin mv 10 15 20 25 30 35 40 85 90 95 100 105 110 115 120 65 70 75 80 60 0 3 2 5 4 7 6 45 $3f7 $3f9 $3f8 $3fb $3fa $3fd $3fc $3fe $3ff $3f4 $3f6 $3f5 8 9 1 2 $ff $fe $fd $3f3 10-bit resolution 8-bit resolution ideal transfer curve 10-bit transfer curve 8-bit transfer curve 55 10-bit absolute error boundary 8-bit absolute error boundary lsb vi-1 vi dnl 5000 +
electrical characteristics mc9s12g family reference manual, rev.1.23 freescale semiconductor 1215 table a-21. adc conversion performance 5v range (junction temperature from ?0 c to +150 c) s12gna16, s12gna32, s12gas48, s12ga64, s12ga96, s12ga128, s12ga192 and s12ga240 supply voltage 4.5v < v dda < 5.5 v, -40 o c < t j < 150 o c, v ref = v rh - v rl = v dda , f adcclk = 8.0mhz the values are tested to be valid with no port ad output drivers switching simultaneous with conversions. num c rating 1 1 the 8-bit and 10-bit mode operation is structurally tested in production test. absolute values are tested in 12-bit mode. symbol min typ max unit 1 p resolution 12-bit lsb 1.25 mv 2 p differential nonlinearity 12-bit dnl -4 2 4 counts 3 p integral nonlinearity 12-bit inl -5 2.5 5 counts 4 p absolute error 2 2 these values include the quantization error which is inherently 1/2 count for any a/d converter. 12-bit ae -7 4 7 counts 5 c resolution 10-bit lsb 5 mv 6 c differential nonlinearity 10-bit dnl -1 0.5 1 counts 7 c integral nonlinearity 10-bit inl -2 1 2 counts 8 c absolute error 2 10-bit ae -3 2 3 counts 9 c resolution 8-bit lsb 20 mv 10 c differential nonlinearity 8-bit dnl -0.5 0.3 0.5 counts 11 c integral nonlinearity 8-bit inl -1 0.5 1 counts 12 c absolute error 2 8-bit ae -1.5 1 1.5 counts
electrical characteristics mc9s12g family reference manual, rev.1.23 1216 freescale semiconductor table a-22. adc conversion performance 5v range (junction temperature from +150 c to +160 c) s12gna16, s12gna32 supply voltage 4.5v < v dda < 5.5 v, +150 o c < t j < 160 o c, v ref = v rh - v rl = v dda , f adcclk = 8.0mhz the values are tested to be valid with no port ad output drivers switching simultaneous with conversions. num c rating 1 1 the 8-bit and 10-bit mode operation is structurally tested in production test. absolute values are tested in 12-bit mode. symbol min typ max unit 1 c resolution 12-bit lsb 1.25 mv 2 c differential nonlinearity 12-bit dnl 2 counts 3 c integral nonlinearity 12-bit inl 2.5 counts 4 c absolute error 2 2 these values include the quantization error which is inherently 1/2 count for any a/d converter. 12-bit ae 4 counts 5 c resolution 10-bit lsb 5 mv 6 c differential nonlinearity 10-bit dnl 0.5 counts 7 c integral nonlinearity 10-bit inl 1 counts 8 c absolute error 2 10-bit ae 2 counts 9 c resolution 8-bit lsb 20 mv 10 c differential nonlinearity 8-bit dnl 0.3 counts 11 c integral nonlinearity 8-bit inl 0.5 counts 12 c absolute error 2 8-bit ae 1 counts
electrical characteristics mc9s12g family reference manual, rev.1.23 freescale semiconductor 1217 table a-23. adc conversion performance 5v range (junction temperature from ?0 c to +150 c) s12gn16, s12gn32, s12gn48, s12g48, s12g64, s12g96, s12g128, s12g192, and s12g240 supply voltage 4.5v < v dda < 5.5 v, -40 o c < t j < 150 o c, v ref = v rh - v rl = v dda , f adcclk = 8.0mhz the values are tested to be valid with no port ad output drivers switching simultaneous with conversions. num c rating 1 1 the 8-bit mode operation is structurally tested in production test. absolute values are tested in 10-bit mode. symbol min typ max unit 1 p resolution 10-bit lsb 5 mv 2 p differential nonlinearity 10-bit dnl -1 0.5 1 counts 3 p integral nonlinearity 10-bit inl -2 1 2 counts 4 p absolute error 2 2 these values include the quantization error which is inherently 1/2 count for any a/d converter. 10-bit 3 10-bit 4 3 lqfp 48 and bigger 4 lqfp 32 and smaller ae -3 -4 2 2 3 4 counts 5 c resolution 8-bit lsb 20 mv 6 c differential nonlinearity 8-bit dnl -0.5 0.3 0.5 counts 7 c integral nonlinearity 8-bit inl -1 0.5 1 counts 8 c absolute error 2 8-bit ae -1.5 1 1.5 counts
electrical characteristics mc9s12g family reference manual, rev.1.23 1218 freescale semiconductor table a-24. adc conversion performance 5v range (junction temperature from +150 c to +160 c) table a-25. adc conversion performance 3.3v range (junction temperature from ?0 c to +150 c) s12gn16, s12gn32 supply voltage 4.5v < v dda < 5.5 v, 150 o c < t j < 160 o c, v ref = v rh - v rl = v dda , f adcclk = 8.0mhz the values are tested to be valid with no port ad output drivers switching simultaneous with conversions. num c rating 1 1 the 8-bit mode operation is structurally tested in production test. absolute values are tested in 10-bit mode. symbol min typ max unit 1 c resolution 10-bit lsb 5 mv 2 c differential nonlinearity 10-bit dnl 0.5 counts 3 c integral nonlinearity 10-bit inl 1 counts 4 c absolute error 2 2 these values include the quantization error which is inherently 1/2 count for any a/d converter. 10-bit 3 10-bit 4 3 lqfp 48 and bigger 4 lqfp 32 and smaller ae 2 2 counts 5 c resolution 8-bit lsb 20 mv 6 c differential nonlinearity 8-bit dnl 0.3 counts 7 c integral nonlinearity 8-bit inl 0.5 counts 8 c absolute error 2 8-bit ae 1 counts s12gna16, s12gna32, s12gas48, s12ga64, s12ga96, s12ga128, s12ga192 and s12ga240 supply voltage 3.13v < v dda < 4.5 v, -40 o c < t j < 150 o c, v ref = v rh - v rl = v dda , f adcclk = 8.0mhz the values are tested to be valid with no port ad output drivers switching simultaneous with conversions. num c rating 1 1 the 8-bit and 10-bit mode operation is structurally tested in production test. absolute values are tested in 12-bit mode. symbol min typ max unit 1 p resolution 12-bit lsb 0.80 mv 2 p differential nonlinearity 12-bit dnl -6 3 6 counts 3 p integral nonlinearity 12-bit inl -7 3 7 counts 4 p absolute error 2 12-bit ae -8 4 8 counts 5 c resolution 10-bit lsb 3.22 mv 6 c differential nonlinearity 10-bit dnl -1.5 1 1.5 counts 7 c integral nonlinearity 10-bit inl -2 1 2 counts 8 c absolute error 2 10-bit ae -3 2 3 counts 9 c resolution 8-bit lsb 12.89 mv 10 c differential nonlinearity 8-bit dnl -0.5 0.3 0.5 counts 11 c integral nonlinearity 8-bit inl -1 0.5 1 counts 12 c absolute error 2 8-bit ae -1.5 1 1.5 counts
electrical characteristics mc9s12g family reference manual, rev.1.23 freescale semiconductor 1219 table a-26. adc conversion performance 3.3v range (junction temperature from +150 c to +160 c) table a-27. adc conversion performance 3.3v range (junction temperature from ?0 c to +150 c) 2 these values include the quantization error which is inherently 1/2 count for any a/d converter. s12gna16, s12gna32 supply voltage 3.13v < v dda < 4.5 v, 150 o c < t j < 160 o c, v ref = v rh - v rl = v dda , f adcclk = 8.0mhz the values are tested to be valid with no port ad output drivers switching simultaneous with conversions. num c rating 1 1 the 8-bit and 10-bit mode operation is structurally tested in production test. absolute values are tested in 12-bit mode. symbol min typ max unit 1 c resolution 12-bit lsb 0.80 mv 2 c differential nonlinearity 12-bit dnl 3 counts 3 c integral nonlinearity 12-bit inl 3 counts 4 c absolute error 2 2 these values include the quantization error which is inherently 1/2 count for any a/d converter. 12-bit ae 4 counts 5 c resolution 10-bit lsb 3.22 mv 6 c differential nonlinearity 10-bit dnl 1 counts 7 c integral nonlinearity 10-bit inl 1 counts 8 c absolute error 2 10-bit ae 2 counts 9 c resolution 8-bit lsb 12.89 mv 10 c differential nonlinearity 8-bit dnl 0.3 counts 11 c integral nonlinearity 8-bit inl 0.5 counts 12 c absolute error 2 8-bit ae 1 counts s12gn16, s12gn32, s12gn48, s12g48, s12g64, s12g96, s12g128, s12g192, and s12g240 supply voltage 3.13v < v dda < 4.5 v, -40 o c < t j < 150 o c, v ref = v rh - v rl = v dda , f adcclk = 8.0mhz the values are tested to be valid with no port ad output drivers switching simultaneous with conversions. num c rating 1 symbol min typ max unit 1 p resolution 10-bit lsb 3.22 mv 2 p differential nonlinearity 10-bit dnl -1.5 1 1.5 counts 3 p integral nonlinearity 10-bit inl -2 1 2 counts 4 p absolute error 2 10-bit 3 10-bit 4 ae -3 -4 2 2 3 4 counts 5 c resolution 8-bit lsb 12.89 mv 6 c differential nonlinearity 8-bit dnl -0.5 0.3 0.5 counts 7 c integral nonlinearity 8-bit inl -1 0.5 1 counts 8 c absolute error 2 8-bit ae -1.5 1 1.5 counts
electrical characteristics mc9s12g family reference manual, rev.1.23 1220 freescale semiconductor table a-28. adc conversion performance 3.3v range (junction temperature from +150 c to +160 c) 1 the 8-bit mode operation is structurally tested in production test. absolute values are tested in 10-bit mode. 2 these values include the quantization error which is inherently 1/2 count for any a/d converter. 3 lqfp 48 and bigger 4 lqfp 32 and smaller s12gn16, s12gn32 supply voltage 3.13v < v dda < 4.5 v, 150 o c < t j < 160 o c, v ref = v rh - v rl = v dda , f adcclk = 8.0mhz the values are tested to be valid with no port ad output drivers switching simultaneous with conversions. num c rating 1 1 the 8-bit mode operation is structurally tested in production test. absolute values are tested in 10-bit mode. symbol min typ max unit 1 c resolution 10-bit lsb 3.22 mv 2 c differential nonlinearity 10-bit dnl 1 counts 3 c integral nonlinearity 10-bit inl 1 counts 4 c absolute error 2 2 these values include the quantization error which is inherently 1/2 count for any a/d converter. 10-bit 3 10-bit 4 3 lqfp 48 and bigger 4 lqfp 32 and smaller ae 2 2 counts 5 c resolution 8-bit lsb 12.89 mv 6 c differential nonlinearity 8-bit dnl 0.3 counts 7 c integral nonlinearity 8-bit inl 0.5 counts 8 c absolute error 2 8-bit ae 1 counts
electrical characteristics mc9s12g family reference manual, rev.1.23 freescale semiconductor 1221 table a-29. adc conversion performance 5v range, rva enabled supply voltage v dda =5.0 v, -40 o c < t j < 150 o c. v rh = 5.0v. f adcclk = 0.25 .. 2mhz 1 the values are tested to be valid with no port ad/c output drivers switching simultaneous with conversions. 1 upper limit of f adcclk is restricted when rva attenuation mode is engaged. num c rating symbol min typ max unit 1 p resolution 12-bit lsb 0.61 mv 2 p differential nonlinearity 12-bit dnl 3 4 counts 3 p integral nonlinearity 12-bit inl 3.5 5 counts 4 c absolute error 2 2 these values include the quantization error which is inherently 1/2 count for any a/d converter and the error of the internally generated reference values.. 12-bit ae 8 counts 5 p internal vrh reference voltage lqfp48, lqfp64, lqfp100 vvrh_int 4.495 4.505 v kgd vvrh_int 4.490 4.510 v 6 p internal vrl reference voltage lqfp48, lqfp64, lqfp100 vvrh_int 1.995 2.005v v kgd vvrl_int 1.990 2.010v v 7 c vrh_int drift vs temperature 3 3 please note: although different in value, drift of vrh_int and vrl_int will go in the same direction. vvrh_drift -2 2 mv 8 c vrl_int drift vs temperature vvrl_drift -2.5 2.5 mv 9 c rva turn on settling time t settling_on 2.5 s 10 c rva turn off settling time t settling_off 1 s
electrical characteristics mc9s12g family reference manual, rev.1.23 1222 freescale semiconductor a.4.3.2 adc analog input parasitics figure a-2. adc analog input parasitics a.4.4 adc temperature sensor table a-30. adc temperature sensor a.5 acmp characteristics this section describes the electrical characteristics of the analog comparator. num c rating symbol min typ max unit 1 t temperature sensor slope dv ts -4.0 -3.8 -3.6 mv/ c pad00- pad11 vdda vssa t jmax =130 o c i leakp < 0.5 a i leakn < 0.5 a c bottom 3.7pf < s/h cap < 6.2pf (incl parasitics) 920 ? < r path < 9.9k ? (incl parasitics) sampling time is 4 to 24 adc clock cycles of 0.25mhz to 8mhz -> 96 s >= tsample >= 500ns switch resistance depends on input voltage, corner ranges are shown. leakage current is guaranteed by speci?ation. complete 10bit conversion takes between 19 and 41 adc clock cycles connected to low ohmic supply during sampling c top c top potential just prior to sampling is either a) ~ last converted channel potential or b) ground level if s/h discharge feature is enabled.
electrical characteristics mc9s12g family reference manual, rev.1.23 freescale semiconductor 1223 table a-31. acmp electrical characteristics (junction temperature from ?0 c to +150 c) characteristics noted under conditions 3.13v <= vdda <= 5.5v, -40 o c < tj < 150 o c unless otherwise noted. typical values noted re?ct the approximate parameter mean at t a = 25?c under nominal conditions unless otherwise noted. num c ratings symbol min typ max unit 1 d c supply current of acmp module disabled module enabled ? v in > 0.1v i off i run 100 - 180 5 270 a a 2 p common mode input voltage range acmpm, acmpp v in 0-v dda -1.5v v 3 p input offset v offset -40 0 40 mv 4 c input hysteresis v hyst 3 7 20 mv 5 p switch delay for -0.1v to 0.1v input step (w/o synchronize delay) t delay - 0.3 0.6 s table a-32. acmp electrical characteristics (junction temperature from +150 c to +160 c) characteristics noted under conditions 3.13v <= vdda <= 5.5v, -150 o c < tj < 160 o c unless otherwise noted. typical values noted re?ct the approximate parameter mean at t a = 25?c under nominal conditions unless otherwise noted. num c ratings symbol min typ max unit 1 d c supply current of acmp module disabled module enabled ? v in > 0.1v i off i run - 180 a a 2 c common mode input voltage range acmpm, acmpp v in -v 3 c input offset v offset 0mv 4 c input hysteresis v hyst 7mv 5 c switch delay for -0.1v to 0.1v input step (w/o synchronize delay) t delay 0.3 s
electrical characteristics mc9s12g family reference manual, rev.1.23 1224 freescale semiconductor figure a-3. input offset and hysteresis a.6 dac characteristics this section describes the electrical characteristics of the digital to analog converter. table a-33. static electrical characteristics - dac_8b5v characteristics noted under conditions 3.13v <= vdda <= 5.5v>, -40?c < tj < 150?c >, vrh=vdda, vrl=vssa unless otherwise noted. typical values noted re?ct the approximate parameter mean at t a = 25?c under nominal conditions unless otherwise noted. num c ratings symbol min typ max unit 1 d p p supply current of dac_8b5v buffer disabled buffer enabled fvr=0 drive=1 buffer enabled fvr=1 drive=0 i buf - - - - 365 215 5 800 800 a 2 d p reference current reference disabled reference enabled i ref -- 50 1 150 a 3 d resolution 8 bit 4 c relative accuracy @ ampli?r output inl -0.5 +0.5 lsb 5 p differential nonlinearity @ ampli?r output dnl -0.5 +0.5 lsb 6 d dac range a (fvr bit = 1) v out 0...255/256(vrh-vrl)+vrl v 7 d dac range b (fvr bit = 0 v out 32...287/320(vrh-vrl)+vrl v offset hysteresis acmpm acmpp acmpo v t
electrical characteristics mc9s12g family reference manual, rev.1.23 freescale semiconductor 1225 a.7 nvm a.7.1 timing parameters the time base for all nvm program or erase operations is derived from the bus clock using the fclkdiv register. the frequency of this derived clock must be set within the limits speci?d as f nvmop . the nvm module does not have any means to monitor the frequency and will not prevent program or erase operation at frequencies above or below the speci?d minimum. when attempting to program or erase the nvm module at a lower frequency, a full program or erase transition is not assured. the following sections provide equations which can be used to determine the time required to execute speci? ?sh commands. all timing parameters are a function of the bus clock frequency, f nvmbus . all program and erase times are also a function of the nvm operating frequency, f nvmop . a summary of key timing parameters can be found in table a-34 . 8 c output voltage unbuffered range a or b (load >= 50m ? )v out full dac range a or b v 9 p output voltage (drive bit = 0) 1 buffered range a (load >= 100k ? to vssa) buffered range a (load >= 100k ? to vdda) buffered range b (load >= 100k ? to vssa) buffered range b (load >= 100k ? to vdda) v out 0 0.15 - - vdda-0.15 vdda v full dac range b 10 p output voltage (drive bit = 1) 2 buffered range b with 6.4k ? load into resistor divider of 800 ? /6.56k ? between vdda and vssa. (equivalent load is >= 65k ? to vssa) or (equivalent load is >= 7.5k ? to vdda) v out full dac range b v 11 d buffer output capacitive load c load 0 - 100 pf 12 p buffer output offset v offset -30 - +30 mv 13 p settling time t delay -35 s 14 d reverence voltage high v refh vdda-0.1v vdda vdda+0.1v v 1 drive bit = 1 is not recommended in this case. 2 drive bit = 0 is not allowed with this high load. table a-33. static electrical characteristics - dac_8b5v characteristics noted under conditions 3.13v <= vdda <= 5.5v>, -40?c < tj < 150?c >, vrh=vdda, vrl=vssa unless otherwise noted. typical values noted re?ct the approximate parameter mean at t a = 25?c under nominal conditions unless otherwise noted. num c ratings symbol min typ max unit
electrical characteristics mc9s12g family reference manual, rev.1.23 1226 freescale semiconductor a.7.1.1 erase verify all blocks (blank check) (fcmd=0x01) the time required to perform a blank check on all blocks is dependent on the location of the ?st non-blank word starting at relative address zero. it takes one bus cycle per phrase to verify plus a setup of the command. assuming that no non-blank location is found, then the time to erase verify all blocks is given by: ftmrg240k2, ftmrg192k2: ftmrg128k1,ftmrg96k1: ftmrg64k1, ftmrg48k1: ftmrg32k1,ftmrg16k1: a.7.1.2 erase verify block (blank check) (fcmd=0x02) the time required to perform a blank check is dependent on the location of the ?st non-blank word starting at relative address zero. it takes one bus cycle per phrase to verify plus a setup of the command. assuming that no non-blank location is found, then the time to erase verify a p-flash block is given by: ftmrg240k2, ftmrg192k2: ftmrg128k1, ftmrg96k1: t check 64400 1 f nvmbus --------------------- ? = t check 33600 1 f nvmbus --------------------- ? = t check 18000 1 f nvmbus --------------------- ? = t check 9300 1 f nvmbus --------------------- ? = t pcheck 62200 1 f nvmbus --------------------- ? = t pcheck 33400 1 f nvmbus --------------------- ? =
electrical characteristics mc9s12g family reference manual, rev.1.23 freescale semiconductor 1227 ftmrg64k1, ftmrg48k1: ftmrg32k1, ftmrg16k1: assuming that no non-blank location is found, then the time to erase verify a eeprom block is given by: ftmrg240k2, ftmrg192k2: ftmrg128k1, ftmrg96k1: ftmrg64k1, ftmrg48k1: ftmrg32k1, ftmrg16k1: a.7.1.3 erase verify p-flash section (fcmd=0x03) the maximum time to erase verify a section of p-flash depends on the number of phrases being veri?d (n vp ) and is given by: a.7.1.4 read once (fcmd=0x04) the maximum read once time is given by: t pcheck 16700 1 f nvmbus --------------------- ? = t pcheck 33400 1 f nvmbus --------------------- ? = t dcheck 2620 1 f nvmbus --------------------- ? = t dcheck 2620 1 f nvmbus --------------------- ? = t dcheck 1540 1 f nvmbus --------------------- ? = t dcheck 2620 1 f nvmbus --------------------- ? = t 550 n vp + () 1 f nvmbus --------------------- ? t 550 1 f nvmbus --------------------- ? =
electrical characteristics mc9s12g family reference manual, rev.1.23 1228 freescale semiconductor a.7.1.5 program p-flash (fcmd=0x06) the programming time for a single phrase of four p-flash words and the two seven-bit ecc ?lds is dependent on the bus frequency, f nvmbus , as well as on the nvm operating frequency, f nvmop . the typical phrase programming time is given by: the maximum phrase programming time is given by: a.7.1.6 program once (fcmd=0x07) the maximum time required to program a p-flash program once ?ld is given by: a.7.1.7 erase all blocks (fcmd=0x08) the time required to erase all blocks is given by: ftmrg240k2, ftmrg192k2: ftmrg128k1, ftmrg96k1: ftmrg64k1, ftmrg48k1: ftmrg32k1, ftmrg16k1: t ppgm 62 1 f nvmop ------------------ 2900 1 f nvmbus --------------------- ? + ? t ppgm 62 1 f nvmop ------------------ 3100 1 f nvmbus --------------------- ? + ? t62 1 f nvmop ------------------ 2900 1 f nvmbus --------------------- ? + ? t mass 200130 1 f nvmop ------------------ 65000 1 f nvmbus --------------------- ? + ? t mass 100068 1 f nvmop ------------------ 33500 1 f nvmbus --------------------- ? + ? t mass 100068 1 f nvmop ------------------ 18300 1 f nvmbus --------------------- ? + ? t mass 100068 1 f nvmop ------------------ 9600 1 f nvmbus --------------------- ? + ?
electrical characteristics mc9s12g family reference manual, rev.1.23 freescale semiconductor 1229 a.7.1.8 erase p-flash block (fcmd=0x09) the time required to erase the p-flash block is given by: ftmrg240k2, ftmrg192k1: ftmrg128k1, ftmrg96k1: ftmrg64k1, ftmrg64k1: ftmrg32k1, ftmrg16k1: a.7.1.9 erase p-flash sector (fcmd=0x0a) the typical time to erase a 512-byte p-flash sector is given by: the maximum time to erase a 512-byte p-flash sector is given by: a.7.1.10 unsecure flash (fcmd=0x0b) the maximum time required to erase and unsecure the flash is given by: ftmrg240k2, ftmrg192k2: t pmass 200124 1 f nvmop ------------------ 62700 1 f nvmbus --------------------- ? + ? t pmass 100062 1 f nvmop ------------------ 31300 1 f nvmbus --------------------- ? + ? t pmass 100062 1 f nvmop ------------------ 17100 1 f nvmbus --------------------- ? + ? t pmass 100062 1 f nvmop ------------------ 9000 1 f nvmbus --------------------- ? + ? t pera 20400 1 f nvmop ------------------ ? 720 1 f nvmbus --------------------- ? + t pera 20400 1 f nvmop ------------------ ? 1700 1 f nvmbus --------------------- ? + t uns 200130 1 f nvmop ------------------ 65100 1 f nvmbus --------------------- ? + ?
electrical characteristics mc9s12g family reference manual, rev.1.23 1230 freescale semiconductor ftmrg128k1, ftmrg96k1: ftmrg64k1, ftmrg48k1: ftmrg32k1, ftmrg16k1: a.7.1.11 verify backdoor access key (fcmd=0x0c) the maximum verify backdoor access key time is given by: a.7.1.12 set user margin level (fcmd=0x0d) the maximum set user margin level time is given by: a.7.1.13 set field margin level (fcmd=0x0e) the maximum set ?ld margin level time is given by: a.7.1.14 erase verify eeprom section (fcmd=0x10) the time required to erase verify eeprom for a given number of words n w is given by: t uns 100070 1 f nvmop ------------------ 33500 1 f nvmbus --------------------- ? + ? t uns 100070 1 f nvmop ------------------ 18300 1 f nvmbus --------------------- ? + ? t uns 100070 1 f nvmop ------------------ 9600 1 f nvmbus --------------------- ? + ? t 520 1 f nvmbus --------------------- ? = t 500 1 f nvmbus --------------------- ? = t 510 1 f nvmbus --------------------- ? = t dcheck 520 n w + () 1 f nvmbus --------------------- ?
electrical characteristics mc9s12g family reference manual, rev.1.23 freescale semiconductor 1231 a.7.1.15 program eeprom (fcmd=0x11) eeprom programming time is dependent on the number of words being programmed and their location with respect to a row boundary since programming across a row boundary requires extra steps. the typical eeprom programming time is given by the following equation, where n w denotes the number of words: the maximum eeprom programming time is given by: a.7.1.16 erase eeprom sector (fcmd=0x12) typical eeprom sector erase times, expected on a new device where no margin verify fails occur, is given by: maximum eeprom sector erase times is given by: the eeprom sector erase time is ~5ms on a new device and can extend to ~20ms as the ?sh is cycled. t dpgm 34 n w ? () 1 f nvmop ------------------ ? ? ? ? ? 600 940 n w ? () + () 1 f nvmbus --------------------- ? ? ? ? ? + t dpgm 34 n w ? () 1 f nvmop ------------------ ? ? ? ? ? 600 1020 ( n w ) ? + () 1 f nvmbus --------------------- ? ? ? ? ? + t dera 5025 1 f nvmop ------------------ 710 1 f nvmbus --------------------- ? + ? t dera 20400 1 f nvmop ------------------ 750 1 f nvmbus --------------------- ? + ?
electrical characteristics mc9s12g family reference manual, rev.1.23 1232 freescale semiconductor table a-34. nvm timing characteristics num c rating symbol min typ 1 max 2 unit 3 1 bus frequency f nvmbus 1 25 mhz 2 operating frequency f nvmop 0.8 1.0 1.05 mhz 3 d erase all blocks (mass erase) time (ftmrg240k2, tmrg192k2) t mass 200 260 ms erase all blocks (mass erase) time (ftmrg128k1, ftmrg96k1) t mass 100 130 ms erase all blocks (mass erase) time (ftmrg128k1, ftmrg96k1) t mass 100 130 ms erase all blocks (mass erase) time (ftmrg32k1, ftmrg16k1 t mass 100 130 ms 4 d erase verify all blocks (blank check) time (ftmrg240k2, tmrg192k2) t check 64400 t cyc erase verify all blocks (blank check) time (ftmrg128k1, ftmrg96k1) t check 33600 t cyc erase verify all blocks (blank check) time (ftmrg64k1, ftmrg48k1) t check 18000 t cyc erase verify all blocks (blank check) time (ftmrg32k1, ftmrg16k1) t check 9300 t cyc 5 d unsecure flash time (ftmrg240k2, tmrg192k2) t uns 200 260 ms unsecure flash time (ftmrg128k1, ftmrg96k1) t uns 100 130 ms unsecure flash time (ftmrg64k1, ftmrg48k1) t uns 100 130 ms unsecure flash time (ftmrg32k1, ftmrg16k1) t uns 100 130 ms 6 d p-flash block erase time (ftmrg240k2, tmrg192k2) t pmass 200 260 ms p-flash block erase time (ftmrg128k1, ftmrg96k1) t pmass 100 130 ms p-flash block erase time (ftmrg64k1, ftmrg48k1) t pmass 100 130 ms p-flash block erase time (ftmrg32k1, ftmrg16k1) t pmass 100 130 ms 7 d p-flash erase verify (blank check) time (ftmrg240k2, ftmrg192k2) t pcheck 62200 t cyc p-flash erase verify (blank check) time (ftmrg128k1, ftmrg96k1) t pcheck 33400 t cyc p-flash erase verify (blank check) time (ftmrg64k1, ftmrg48k1) t pcheck 16700 t cyc p-flash erase verify (blank check) time (ftmrg32k1, ftmrg16k1) t pcheck 33400 t cyc
electrical characteristics mc9s12g family reference manual, rev.1.23 freescale semiconductor 1233 a.7.2 nvm reliability parameters the reliability of the nvm blocks is guaranteed by stress test during quali?ation, constant process monitors and burn-in to screen early life failures. the data retention and program/erase cycling failure rates are speci?d at the operating conditions noted. the program/erase cycle count on the sector is incremented every time a sector or mass erase event is executed. 8 d p-flash sector erase time t pera ?026ms 9 d p-flash phrase programming time t ppgm 185 200 s 10 d eeprom sector erase time t dera ? 4 26 ms 11 d eeprom erase verify (blank check) time (ftmrg240k2, tmrg192k2) t dcheck 2620 t cyc eeprom erase verify (blank check) time (ftmrg128k1, ftmrg96k1) t dcheck 2620 t cyc eeprom erase verify (blank check) time (ftmrg64k1, ftmrg48k1) t dcheck 1540 t cyc eeprom erase verify (blank check) time (ftmrg32k1, ftmrg16k1) t dcheck 1030 t cyc 12a d eeprom one word programming time t dpgm1 97 106 s 12b d eeprom two word programming time t dpgm2 140 154 s 1 typical program and erase times are based on typical f nvmop and maximum f nvmbus 2 maximum program and erase times are based on minimum f nvmop and maximum f nvmbus 3 t cyc = 1 / f nvmbus 4 typical value for a new device num c rating symbol min typ 1 max 2 unit 3
electrical characteristics mc9s12g family reference manual, rev.1.23 1234 freescale semiconductor a.8 phase locked loop a.8.1 jitter de?itions with each transition of the feedback clock, the deviation from the reference clock is measured and input voltage to the vco is adjusted accordingly.the adjustment is done continuously with no abrupt changes in the vcoclk frequency. noise, voltage, temperature and other factors cause slight variations in the control loop resulting in a clock jitter. this jitter affects the real minimum and maximum clock periods as illustrated in figure a-4 . table a-35. nvm reliability characteristics conditions are shown in table a-4 unless otherwise noted num c rating symbol min typ max unit program flash arrays 1 c data retention at an average junction temperature of t javg = 85 c 1 after up to 10,000 program/erase cycles 1 t javg does not exceed 85 c in a typical temperature pro?e over the lifetime of a consumer, industrial or automotive application. t nvmret 20 100 2 2 typical data retention values are based on intrinsic capability of the technology measured at high temperature and de-rated to 25 c using the arrhenius equation. for additional information on how freescale de?es typical data retention, please refer to engineering bulletin eb618 years 2 c program flash number of program/erase cycles (-40 c tj 150 c ) n flpe 10k 100k 3 3 spec table quotes typical endurance evaluated at 25 c for this product family. for additional information on how freescale de?es typical endurance, please refer to engineering bulletin eb619. cycles eeprom array 3 c data retention at an average junction temperature of t javg = 85 c 1 after up to 100,000 program/erase cycles t nvmret 5 100 2 years 4 c data retention at an average junction temperature of t javg = 85 c 1 after up to 10,000 program/erase cycles t nvmret 10 100 2 years 5 c data retention at an average junction temperature of t javg = 85 c 1 after less than 100 program/erase cycles t nvmret 20 100 2 years 6 c eeprom number of program/erase cycles (-40 c tj 150 c ) n flpe 100k 500k 3 cycles
electrical characteristics mc9s12g family reference manual, rev.1.23 freescale semiconductor 1235 figure a-4. jitter de?itions the relative deviation of t nom is at its maximum for one clock period, and decreases towards zero for larger number of clock periods (n). de?ing the jitter as: for n < 100, the following equation is a good ? for the maximum jitter: figure a-5. maximum bus clock jitter approximation note on timers and serial modules a prescaler will eliminate the effect of the jitter to a large extent. 2 3 n-1 n 1 0 t nom t max1 t min1 t maxn t minn jn () max 1 t max n () nt nom ? ----------------------- 1 t min n () nt nom ? ---------------------- - , ?? ?? ?? = jn () j 1 n -------- = 1 5 10 20 n j(n)
electrical characteristics mc9s12g family reference manual, rev.1.23 1236 freescale semiconductor a.8.2 electrical characteristics for the pll a.9 electrical characteristics for the irc1m table a-36. pll characteristics conditions are shown in table a-15 unless otherwise noted num c rating symbol min typ max unit 1 d vco frequency during system reset f vcorst 8 25 mhz 2 c vco locking range f vco 32 50 mhz 3 c reference clock f ref 1 mhz 4 d lock detection |? lock | 0 1.5 % 1 1 % deviation from target frequency 5 d un-lock detection |? unl | 0.5 2.5 % 1 6 c time to lock t lock 150 + 256/f ref s 7 c jitter ? parameter 1 2 irc as reference clock source 2 f ref = 1mhz (irc), f bus = 25mhz equivalent f pll = 50mhz, cpmusynr=0x58, cpmurefdiv=0x00, cpmupostdiv=0x00 j irc 1.4 % 8 c jitter ? parameter 1 3 xosclcp as reference clock source 3 f ref = 4mhz (xosclcp), f bus = 24mhz equivalent f pll = 48mhz, cpmusynr=0x05, cpmurefdiv=0x40, cpmupostdiv=0x00 j ext 1.0 % table a-37. irc1m characteristics (junction temperature from ?0 c to +150 c, all packages) conditions are: temperature option c, v, or m (see table a-4 ) num c rating symbol min typ max unit 1 p internal reference frequency, factory trimmed f irc1m_trim 0.987 1 1.013 mhz table a-38. irc1m characteristics (junction temperature from ?0 c to +150 c, kgd) conditions are: temperature option c, v, or m (see table a-4 ) num c rating symbol min typ max unit 1 p internal reference frequency, factory trimmed f irc1m_trim 0.980 1 1.020 mhz
electrical characteristics mc9s12g family reference manual, rev.1.23 freescale semiconductor 1237 table a-39. irc1m characteristics (junction temperature from +150 c to +160 c, all packages) conditions are: temperature option w (see table a-4 ) num c rating symbol min typ max unit 1 c internal reference frequency, factory trimmed f irc1m_trim 0.987 1 1.013 mhz
electrical characteristics mc9s12g family reference manual, rev.1.23 1238 freescale semiconductor a.10 electrical characteristics for the oscillator (xosclcp) table a-40. xosclcp characteristics (junction temperature from ?0 c to +150 c) conditions are shown in table a-4 unless otherwise noted num c rating symbol min typ max unit 1 c nominal crystal or resonator frequency f osc 4.0 16 mhz 2 p startup current i osc 100 a 3a c oscillator start-up time (4mhz) 1 1 these values apply for carefully designed pcb layouts with capacitors that match the crystal/resonator requirements. t uposc 2 10 ms 3b c oscillator start-up time (8mhz) 1 t uposc 1.6 8 ms 3c c oscillator start-up time (16mhz) 1 t uposc 15ms 4 p clock monitor failure assert frequency f cmfa 200 450 1200 khz 5 d input capacitance (extal, xtal pins) c in 7pf 6 c extal pin input hysteresis v hys,extal 120 mv 7 c extal pin oscillation amplitude (loop controlled pierce) all mask sets except for 2n75c v pp,extal 1.0 v 8 d extal pin oscillation required amplitude 2 (loop controlled pierce) all mask sets except for 2n75c 2 needs to be measured at room temperature on the application board using a probe with very low (<=5pf) input capacitance. v pp,extal 0.8 1.5 v
electrical characteristics mc9s12g family reference manual, rev.1.23 freescale semiconductor 1239 a.11 reset characteristics table a-41. xosclcp characteristics (junction temperature from +150 c to +160 c) conditions are shown in table a-4 unless otherwise noted num c rating symbol min typ max unit 1 c nominal crystal or resonator frequency f osc 4.0 16 mhz 2 c startup current i osc 100 a 3a c oscillator start-up time (4mhz) 1 1 these values apply for carefully designed pcb layouts with capacitors that match the crystal/resonator requirements. t uposc 2 10 ms 3b c oscillator start-up time (8mhz) 1 t uposc 1.6 8 ms 3c c oscillator start-up time (16mhz) 1 t uposc 15ms 4 p clock monitor failure assert frequency f cmfa 200 450 1200 khz 5 d input capacitance (extal, xtal pins) c in 7pf 6 c extal pin input hysteresis v hys,extal 120 mv 7 c extal pin oscillation amplitude (loop controlled pierce) all mask sets except for 2n75c v pp,extal 1.0 v 8 d extal pin oscillation required amplitude 2 (loop controlled pierce) all mask sets except for 2n75c 2 needs to be measured at room temperature on the application board using a probe with very low (<=5pf) input capacitance. v pp,extal 0.8 1.5 v table a-42. reset and stop characteristics conditions are shown in table a-4 unless otherwise noted num c rating symbol min typ max unit 1 c reset input pulse width, minimum input time pw rstl 2t vcorst 2 c startup from reset n rst 768 t vcorst 3 c stop recovery time t stp_rec 23 s
electrical characteristics mc9s12g family reference manual, rev.1.23 1240 freescale semiconductor a.12 electrical speci?ation for voltage regulator table a-43. voltage regulator characteristics (junction temperature from ?0 c to +150 c) num c characteristic symbol min typical max unit 1 p input voltages v vddr,a 3.13 5.5 v 2 p v dda low voltage interrupt assert level 1 v dda low voltage interrupt deassert level 1 monitors vdda, active only in full performance mode. indicates i/o & adc performance degradation due to low supply voltage. v lvia v lvid 4.04 4.19 4.23 4.38 4.40 4.49 v v 3 p v ddx low voltage reset deassert 234 2 device functionality is guaranteed on power down to the lvr assert level 3 monitors vddx, active only in full performance mode. mcu is monitored by the por in rpm (see figure a-6 ) 4 v lvrxa < v lvrxd . the hysteresis is unspeci?d and untested. v lvrxd 3.05 3.13 v 4 p v ddx low voltage reset assert 234 v lvrxa 2.95 3.02 v 5 t cpmu aclk frequency (cpmuaclktr[5:0] = %000000) f aclk 10 khz 6 c trimmed aclk internal clock 5 ? f / f nominal 5 the aclk trimming cpmuaclktr[5:0] bits must be set so that f aclk =10khz. df aclk - 5% + 5% 7 d the first period after enabling the counter by apife might be reduced by aclk start up delay t sdel 100 us 8 d the first period after enabling the cop might be reduced by aclk start up delay t sdel 100 us 9 p output voltage flash full performance mode reduced power mode (mcu stop mode) v ddf 2.6 1.1 2.82 1.6 2.9 1.98 v v 10 c v ddf voltage distribution over input voltage v dda 6 4.5v v dda 5.5v, t a = 27 o c compared to v dda = 5.0v 6 vddr 3.13v ? vddf -5 0 5 mv 11 c v ddf voltage distribution over ambient temperature t a v dda = 5v, -40 c t a 125 c compared to v ddf production test value (see a.16, ?dc conversion result reference ) ? vddf -20 - +20 mv
electrical characteristics mc9s12g family reference manual, rev.1.23 freescale semiconductor 1241 note the lvr monitors the voltages v dd ,v ddf and v ddx . as soon as voltage drops on these supplies which would prohibit the correct function of the microcontroller, the lvr is triggering a reset. table a-44. voltage regulator characteristics (junction temperature from +150 c to +160 c) num c characteristic symbol min typical max unit 1 c input voltages v vddr,a 3.13 5.5 v 2 c v dda low voltage interrupt assert level 1 v dda low voltage interrupt deassert level 1 monitors vdda, active only in full performance mode. indicates i/o & adc performance degradation due to low supply voltage. v lvia v lvid 4.04 4.19 4.23 4.38 4.40 4.49 v v 3 c v ddx low voltage reset deassert 234 2 device functionality is guaranteed on power down to the lvr assert level 3 monitors vddx, active only in full performance mode. mcu is monitored by the por in rpm (see figure a-6 ) 4 v lvrxa < v lvrxd . the hysteresis is unspeci?d and untested. v lvrxd 3.05 3.13 v 4 c v ddx low voltage reset assert 234 v lvrxa 2.95 3.02 v 5 t cpmu aclk frequency (cpmuaclktr[5:0] = %000000) f aclk 10 khz 6 c trimmed aclk internal clock 5 ? f / f nominal 5 the aclk trimming cpmuaclktr[5:0] bits must be set so that f aclk =10khz. df aclk - 5% + 5% 7 d the first period after enabling the counter by apife might be reduced by aclk start up delay t sdel 100 us 8 d the first period after enabling the cop might be reduced by aclk start up delay t sdel 100 us 9 c output voltage flash full performance mode reduced power mode (mcu stop mode) v ddf 2.6 1.1 2.82 1.6 2.9 1.98 v v 10 c v ddf voltage distribution over input voltage v dda 6 4.5v v dda 5.5v, t a = 27 o c compared to v dda = 5.0v 6 vddr 3.13v ? vddf -5 0 5 mv 11 c v ddf voltage distribution over ambient temperature t a v dda = 5v, -40 c t a 125 c compared to v ddf production test value (see a.16, ?dc conversion result reference ) ? vddf -20 - +20 mv
electrical characteristics mc9s12g family reference manual, rev.1.23 1242 freescale semiconductor a.13 chip power-up and voltage drops lvi (low voltage interrupt), por (power-on reset) and lvrs (low voltage reset) handle chip power-up or drops of the supply voltage. figure a-6. chip power-up and voltage drops a.14 mscan table a-45. mscan wake-up pulse characteristics conditions are shown in table a-4 unless otherwise noted num c rating symbol min typ max unit 1 p mscan wakeup dominant pulse ?tered t wup 1.5 s 2 p mscan wakeup dominant pulse pass t wup 5 s v lvid v lvia v lvrd v lvra v pord lvi por lvr t v v dda /v ddx v dd lvi enabled lvi disabled due to lvr
electrical characteristics mc9s12g family reference manual, rev.1.23 freescale semiconductor 1243 a.15 spi timing this section provides electrical parametrics and ratings for the spi. in table a-46 the measurement conditions are listed. a.15.1 master mode in figure a-7 the timing diagram for master mode with transmission format cpha = 0 is depicted. figure a-7. spi master timing (cpha = 0) table a-46. measurement conditions conditions are 4.5 v < v dd35 < 5.5 v junction temperature from ?0 c to t jmax description value unit drive mode full drive mode load capacitance c load 1 , on all outputs 1 timing speci?d for equal load on all spi output pins. avoid asymmetric load. 50 pf thresholds for delay measurement points (35% / 65%) v ddx v sck (output) sck (output) miso (input) mosi (output) ss (output) 1 9 5 6 msb in2 bit msb-1. . . 1 lsb in msb out2 lsb out bit msb-1. . . 1 11 4 4 2 10 (cpol = 0) (cpol = 1) 3 13 13 1. if con?ured as an output. 2. lsbf = 0. for lsbf = 1, bit order is lsb, bit 1, bit 2... msb. 12 12
electrical characteristics mc9s12g family reference manual, rev.1.23 1244 freescale semiconductor in figure a-8 the timing diagram for master mode with transmission format cpha=1 is depicted. figure a-8. spi master timing (cpha = 1) sck (output) sck (output) miso (input) mosi (output) 1 5 6 msb in2 bit msb-1. . . 1 lsb in master msb out2 master lsb out bit msb-1. . . 1 4 4 9 12 13 11 port data (cpol = 0) (cpol = 1) port data ss (output) 2 12 13 3 1.if con?ured as output 2. lsbf = 0. for lsbf = 1, bit order is lsb, bit 1,bit 2... msb.
electrical characteristics mc9s12g family reference manual, rev.1.23 freescale semiconductor 1245 in table a-47 the timing characteristics for master mode are listed. a.15.2 slave mode in figure a-9 the timing diagram for slave mode with transmission format cpha = 0 is depicted. figure a-9. spi slave timing (cpha = 0) table a-47. spi master mode timing characteristics conditions are 4.5 v < v dd35 < 5.5 v junction temperature from ?0 c to t jmax . num c characteristic symbol min typ max unit 1 d sck frequency f sck 1/2048 1 / 2 f bus 1 d sck period t sck 2 2048 t bus 2 d enable lead time t l 1/2 t sck 3 d enable trail time t t 1/2 t sck 4 d clock (sck) high or low time t wsck 1/2 t sck 5 d data setup time (inputs) t su 8ns 6 d data hold time (inputs) t hi 8ns 9 d data valid after sck edge t vsck 15 ns 10 d data valid after ss fall (cpha=0) t vss 15 ns 11 d data hold time (outputs) t ho 0ns 12 d rise and fall time inputs t r 9 ns 13 d rise and fall time outputs t rfo 9 ns sck (input) sck (input) mosi (input) miso (output) ss (input) 1 9 5 6 msb in bit msb-1 . . . 1 lsb in slave msb slave lsb out bit msb-1. . . 1 11 4 4 2 7 (cpol = 0) (cpol = 1) 3 13 note: not de?ed 12 12 11 see 13 note 8 10 see note
electrical characteristics mc9s12g family reference manual, rev.1.23 1246 freescale semiconductor in figure a-10 the timing diagram for slave mode with transmission format cpha = 1 is depicted. figure a-10. spi slave timing (cpha = 1) sck (input) sck (input) mosi (input) miso (output) 1 5 6 msb in bit msb-1 . . . 1 lsb in msb out slave lsb out bit msb-1 . . . 1 4 4 9 12 13 11 (cpol = 0) (cpol = 1) ss (input) 2 12 13 3 note: not de?ed slave 7 8 see note
electrical characteristics mc9s12g family reference manual, rev.1.23 freescale semiconductor 1247 in table a-48 the timing characteristics for slave mode are listed. a.16 adc conversion result reference the reference voltage v ddf is measured under the conditions shown in table a-49 . the value stored in the ifr is the average of eight consecutive conversions at t j =150 c and eight consecutive conversions at t j =-40 c . table a-48. spi slave mode timing characteristics conditions are 4.5 v < v dd35 < 5.5 v junction temperature from ?0 c to t jmax . num c characteristic symbol min typ max unit 1 d sck frequency f sck dc 1 / 4 f bus 1 d sck period t sck 4 t bus 2 d enable lead time t l 4 t bus 3 d enable trail time t t 4 t bus 4 d clock (sck) high or low time t wsck 4 t bus 5 d data setup time (inputs) t su 8 ns 6 d data hold time (inputs) t hi 8 ns 7d slave access time (time to data active) t a 20 ns 8 d slave miso disable time t dis 22 ns 9 d data valid after sck edge t vsck 1 1 0.5t bus added due to internal synchronization delay ns 10 d data valid after ss fall t vss 1 ns 11 d data hold time (outputs) t ho 20 ns 12 d rise and fall time inputs t r 9 ns 13 d rise and fall time outputs t rfo 9 ns table a-49. measurement conditions description symbol value unit regulator supply voltage v ddr 5v i/o supply voltage v ddx 5v analog supply voltage v dda 5v adc reference voltage v rh 5v adc clock f adcclk 2 mhz adc sample time t smp 4 adc clock cycles bus frequency f bus 24 mhz junction temperature t j 150 and -40 c code execution from ram 28 0.5 t bus ? + 28 0.5 t bus ? +
electrical characteristics mc9s12g family reference manual, rev.1.23 1248 freescale semiconductor nvm activity none table a-49. measurement conditions description symbol value unit
detailed register address map mc9s12g family reference manual, rev.1.23 freescale semiconductor 1249 appendix b detailed register address map revision history b.1 detailed register map the following tables show the detailed register map of the mc9s12g-family. note this is a summary of all register bits implemented on mc9s12g devices. each member of the mc9s12g-family implements the subset of registers, which is associated with its feature set (see table 1-1 ). version number revision date description of changes rev 0.05 30-aug-2010 updated adcctl2 register in appendix b, ?etailed register address map . updated cpmuosc register in appendix b, ?etailed register address map . rev 0.06 18-oct-2010 updated adc registers in appendix b, ?etailed register address map . rev 0.07 9-nov-2010 updated cpmu registers in appendix b, ?etailed register address map . rev 0.08 4-dec-2010 updated pim registers in appendix b, ?etailed register address map . rev 0.09 24-apr-2012 typos and formatting 0x0000?x0009 port integration module (pim) map 1 of 6 address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x0000 porta r pa7 pa6 pa5 pa4 pa3 pa2 pa1 pa 0 w 0x0001 portb r pb7 pb6 pb5 pb4 pb3 pb2 pb1 pb0 w 0x0002 ddra r ddra7 ddra6 ddra5 ddra4 ddra3 ddra2 ddra1 ddra0 w 0x0003 ddrb r ddrb7 ddrb6 ddrb5 ddrb4 ddrb3 ddrb2 ddrb1 ddrb0 w 0x0004 portc r pc7 pc6 pc5 pc4 pc3 pc2 pc1 pc0 w 0x0005 portd r pd7 pd6 pd5 pd4 pd3 pd2 pd1 pd0 w 0x0006 ddrc r ddrc7 ddrc6 ddrc5 ddrc4 ddrc3 ddrc2 ddrc1 ddrc0 w 0x0007 ddrd r ddrd7 ddrd6 ddrd5 ddrd4 ddrd3 ddrd2 ddrd1 ddrd0 w 0x0008 porte r000000 pe1 pe0 w 0x0009 ddre r000000 ddre1 ddre0 w
detailed register address map mc9s12g family reference manual, rev.1.23 1250 freescale semiconductor 0x000a?x000b memory map control (mmc) map 1 of 2 address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x000a reserved r00000000 w 0x000b mode r modc 0000000 w 0x000c?x000d port integration module (pim) map 2 of 6 address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x000c pucr r0 bkpue 0 pdpee pupde pupce pupbe pupae w 0x000d reserved r00000000 w 0x000e?x000f reserved address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x000e- 0x000f reserved r00000000 w 0x0010?x0017 memory map control (mmc) map 2 of 2 address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x0010 reserved r00000000 w 0x0011 direct r dp15 dp14 dp13 dp12 dp11 dp10 dp9 dp8 w 0x0012 reserved r00000000 w 0x0013 mmcctl r0000000 nvmres w 0x0014 reserved r00000000 w 0x0015 ppage r0 0 0 0 pix3 pix2 pix1 pix0 w 0x0016- 0x0017 reserved r00000000 w 0x0018?x0019 reserved address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x0018- 0x0019 reserved r00000000 w
detailed register address map mc9s12g family reference manual, rev.1.23 freescale semiconductor 1251 0x001a?x001b device id register (partidh/partidl) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x001a partidh r partidh w 0x001b partidl r partidl w 0x001c?x001f port integration module (pim) map 3 of 6 address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x001c eclkctl r neclk nclkx2 div16 ediv4 ediv3 ediv2 ediv1 ediv0 w 0x001d reserved r00000000 w 0x001e irqcr r irqe irqen 000000 w 0x001f reserved r00000000 w 0x0020?x002f debug module (dbg) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x0020 dbgc1 r arm 00 bdm dbgbrk 0 comrv w trig 0x0021 dbgsr r tbf 0 0 0 0 ssf2 ssf1 ssf0 w 0x0022 dbgtcr r0 tsource 00 trcmod 0 talign w 0x0023 dbgc2 r000000 abcm w 0x0024 dbgtbh r bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 w 0x0025 dbgtbl r bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 w 0x0026 dbgcnt r 1 tbf 0 cnt w 0x0027 dbgscrx r0 0 0 0 sc3 sc2 sc1 sc0 w dbgmfr r 0 0 0 0 0 mc2 mc1 mc0 w 0x0028 dbgactl r sze sz tag brk rw rwe ndb compe w dbgbctl r sze sz tag brk rw rwe 0 compe w dbgcctl r0 0 tag brk rw rwe 0 compe w
detailed register address map mc9s12g family reference manual, rev.1.23 1252 freescale semiconductor 0x0029 dbgxah r000000 bit 17 bit 16 w 0x002a dbgxam r bit 15 14 13 12 11 10 9 bit 8 w 0x002b dbgxal r bit 7 6 54321 bit 0 w 0x002c dbgadh r bit 15 14 13 12 11 10 9 bit 8 w 0x002d dbgadl r bit 7 6 54321 bit 0 w 0x002e dbgadhm r bit 15 14 13 12 11 10 9 bit 8 w 0x002f dbgadlm r bit 7 6 54321 bit 0 w 0x0030?x033 reserved address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x0030- 0x0033 reserved r00000000 w 0x0034?x003f clock and power management (cpmu) map 1 of 2 address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x0034 cpmu synr r vcofrq[1:0] syndiv[5:0] w 0x0035 cpmu refdiv r reffrq[1:0] 00 refdiv[3:0] w 0x0036 cpmu postdiv r0 0 0 postdiv[4:0] w 0x0037 cpmuflg r rtif porf lvrf lockif lock ilaf oscif uposc w 0x0038 cpmuint r rtie 00 lockie 00 oscie 0 w 0x0039 cpmuclks r pllsel pstp 00 pre pce rti oscsel cop oscsel w 0x003a cpmupll r0 0 fm1 fm0 0000 w 0x003b cpmurti r rtdec rtr6 rtr5 rtr4 rtr3 rtr2 rtr1 rtr0 w 0x003c cpmucop r wcop rsbck 000 cr2 cr1 cr0 w wrtmask 0x0020?x002f debug module (dbg) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
detailed register address map mc9s12g family reference manual, rev.1.23 freescale semiconductor 1253 0x003d reserved r00000000 w 0x003e reserved r00000000 w 0x003f cpmu armcop r00000000 w bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x0040?x067 timer module (tim) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x0040 tios r ios7 ios6 ios5 ios4 ios3 ios2 ios1 ios0 w 0x0041 cforc r00000000 w foc7 foc6 foc5 foc4 foc3 foc2 foc1 foc0 0x0042 oc7m r oc7m7 oc7m6 oc7m5 oc7m4 oc7m3 oc7m2 oc7m1 oc7m0 w 0x0043 oc7d r oc7d7 oc7d6 oc7d5 oc7d4 oc7d3 oc7d2 oc7d1 oc7d0 w 0x0044 tcnth r tcnt15 tcnt14 tcnt13 tcnt12 tcnt11 tcnt10 tcnt9 tcnt8 w 0x0045 tcntl r tcnt7 tcnt6 tcnt5 tcnt4 tcnt3 tcnt2 tcnt1 tcnt0 w 0x0046 tscr1 r ten tswai tsfrz tffca prnt 000 w 0x0047 ttov r tov7 tov6 tov5 tov4 tov3 tov2 tov1 tov0 w 0x0048 tctl1 r om7 ol7 om6 ol6 om5 ol5 om4 ol4 w 0x0049 tctl2 r om3 ol3 om2 ol2 om1 ol1 om0 ol0 w 0x004a tctl3 r edg7b edg7a edg6b edg6a edg5b edg5a edg4b edg4a w 0x004b tctl4 r edg3b edg3a edg2b edg2a edg1b edg1a edg0b edg0a w 0x004c tie r c7i c6i c5i c4i c3i c2i c1i c0i w 0x004d tscr2 r toi 000 tcre pr2 pr1 pr0 w 0x004e tflg1 r c7f c6f c5f c4f c3f c2f c1f c0f w 0x004f tflg2 r tof 0000000 w 0x0034?x003f clock and power management (cpmu) map 1 of 2 address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
detailed register address map mc9s12g family reference manual, rev.1.23 1254 freescale semiconductor 0x0050 0x005f tcxh ?tcxl r bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 w r bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 w 0x0060 pactl r0 paen pamod pedge clk1 clk0 paovi pai w 0x0061 paflg r000000 paovf paif w 0x0062 pacnth r pacnt15 pacnt14 pacnt13 pacnt12 pacnt11 pacnt10 pacnt9 pacnt8 w 0x0063 pacntl r pacnt7 pacnt6 pacnt5 pacnt4 pacnt3 pacnt2 pacnt1 pacnt0 w 0x0064- 0x006b reserved r w 0x006c ocpd r ocpd7 ocpd6 ocpd5 ocpd4 ocpd3 ocpd2 ocpd1 ocpd0 w 0x006d reserved r w 0x006e ptpsr r ptps7 ptps6 ptps5 ptps4 ptps3 ptps2 ptps1 ptps0 w 0x006f reserved r w 0x0070?x09f analog to digital converter (adc) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x0070 atdctl0 r reserved 000 wrap3 wrap2 wrap1 wrap0 w 0x0071 atdctl1 r etrigsel sres1 sres0 smp_dis etrigch3 etrigch2 etrigch1 etrigch0 w 0x0072 atdctl2 r0 affc reseved etrigle etrigp etrige ascie acmpie w 0x0073 atdctl3 r djm s8c s4c s2c s1c fifo frz1 frz0 w 0x0074 atdctl4 r smp2 smp1 smp0 prs[4:0] w 0x0075 atdctl5 r0 sc scan mult cd cc cb ca w 0x0076 atdstat0 r scf 0 etorf fifor cc3 cc2 cc1 cc0 w 0x0077 reserved r00000000 w 0x0078 atdcmpeh r cmpe[15:8] w 0x0079 atdcmpel r cmpe[7:0] w 0x0040?x067 timer module (tim)
detailed register address map mc9s12g family reference manual, rev.1.23 freescale semiconductor 1255 0x007a atdstat2h r ccf[15:8] w 0x007b atdstat2l r ccf[7:0] w 0x007c atddienh r ien[15:8] w 0x007d atddienl r ien[7:0] w 0x007e atdcmphth r cmpht[15:8] w 0x007f atdcmphtl r cmpht[7:0] w 0x0080- 0x0091 atddr0 r see section 16.3.2.12.1, ?eft justi?d result data (djm=0) and section 16.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0082- 0x0083 atddr1 r see section 16.3.2.12.1, ?eft justi?d result data (djm=0) and section 16.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0084- 0x0085 atddr2 r see section 16.3.2.12.1, ?eft justi?d result data (djm=0) and section 16.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0086- 0x0087 atddr3 r see section 16.3.2.12.1, ?eft justi?d result data (djm=0) and section 16.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0088- 0x0089 atddr4 r see section 16.3.2.12.1, ?eft justi?d result data (djm=0) and section 16.3.2.12.2, ?ight justi?d result data (djm=1) w 0x008a- 0x008b atddr5 r see section 16.3.2.12.1, ?eft justi?d result data (djm=0) and section 16.3.2.12.2, ?ight justi?d result data (djm=1) w 0x008c- 0x008d atddr6 r see section 16.3.2.12.1, ?eft justi?d result data (djm=0) and section 16.3.2.12.2, ?ight justi?d result data (djm=1) w 0x008e- 0x008f atddr7 r see section 16.3.2.12.1, ?eft justi?d result data (djm=0) and section 16.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0090- 0x0091 atddr8 r see section 16.3.2.12.1, ?eft justi?d result data (djm=0) and section 16.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0092- 0x0093 atddr9 r see section 16.3.2.12.1, ?eft justi?d result data (djm=0) and section 16.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0094- 0x0095 atddr10 r see section 16.3.2.12.1, ?eft justi?d result data (djm=0) and section 16.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0096- 0x0097 atddr11 r see section 16.3.2.12.1, ?eft justi?d result data (djm=0) and section 16.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0098- 0x0099 atddr12 r see section 16.3.2.12.1, ?eft justi?d result data (djm=0) and section 16.3.2.12.2, ?ight justi?d result data (djm=1) w 0x009a- 0x009b atddr13 r see section 16.3.2.12.1, ?eft justi?d result data (djm=0) and section 16.3.2.12.2, ?ight justi?d result data (djm=1) w 0x009c- 0x009d atddr14 r see section 16.3.2.12.1, ?eft justi?d result data (djm=0) and section 16.3.2.12.2, ?ight justi?d result data (djm=1) w 0x009e- 0x009f atddr15 r see section 16.3.2.12.1, ?eft justi?d result data (djm=0) and section 16.3.2.12.2, ?ight justi?d result data (djm=1) w 0x0070?x09f analog to digital converter (adc) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
detailed register address map mc9s12g family reference manual, rev.1.23 1256 freescale semiconductor 0x00a0?x0c7 pulse-width-modulator (pwm) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x00a0 pwme r pwme7 pwme6 pwme5 pwme4 pwme3 pwme2 pwme1 pwme0 w 0x00a1 pwmpol r ppol7 ppol6 ppol5 ppol4 ppol3 ppol2 ppol1 ppol0 w 0x00a2 pwmclk r pclk7 pclkl6 pclk5 pclk4 pclk3 pclk2 pclk1 pclk0 w 0x00a3 pwmprclk r0 pckb2 pckb1 pckb0 0 pcka2 pcka1 pcka0 w 0x00a4 pwmcae r cae7 cae6 cae5 cae4 cae3 cae2 cae1 cae0 w 0x00a5 pwmctl r con67 con45 con23 con01 pswai pfrz 00 w 0x00a6 pwmclkab r pclkab7 pclkab6 pclkab5 pclkab4 pclkab3 pclkab2 pclkab1 pclkab0 w 0x00a7 reserved r00000000 w 0x00a8 pwmscla r bit 7 6 5 4 3 2 1 bit 0 w 0x00a9 pwmsclb r bit 7 6 5 4 3 2 1 bit 0 w 0x00aa - 0x00ab reserved r00000000 w 0x00ac pwmcnt0 r bit 7 6 5 4 3 2 1 bit 0 w00000000 0x00ad pwmcnt1 r bit 7 6 5 4 3 2 1 bit 0 w00000000 0x00ae pwmcnt2 r bit 7 6 5 4 3 2 1 bit 0 w00000000 0x00af pwmcnt3 r bit 7 6 5 4 3 2 1 bit 0 w00000000 0x0b0 pwmcnt4 r bit 7 6 5 4 3 2 1 bit 0 w00000000 0x00b1 pwmcnt5 r bit 7 6 5 4 3 2 1 bit 0 w00000000 0x00b2 pwmcnt6 r bit 7 6 5 4 3 2 1 bit 0 w00000000 0x00b3 pwmcnt7 r bit 7 6 5 4 3 2 1 bit 0 w00000000 0x00b4 pwmper0 r bit 7 6 5 4 3 2 1 bit 0 w 0x00b5 pwmper1 r bit 7 6 5 4 3 2 1 bit 0 w 0x00b6 pwmper2 r bit 7 6 5 4 3 2 1 bit 0 w
detailed register address map mc9s12g family reference manual, rev.1.23 freescale semiconductor 1257 0x00b7 pwmper3 r bit 7 6 5 4 3 2 1 bit 0 w 0x00b8 pwmper4 r bit 7 6 5 4 3 2 1 bit 0 w 0x00b9 pwmper5 r bit 7 6 5 4 3 2 1 bit 0 w 0x00ba pwmper6 r bit 7 6 5 4 3 2 1 bit 0 w 0x00bb pwmper7 r bit 7 6 5 4 3 2 1 bit 0 w 0x00bc pwmdty0 r bit 7 6 5 4 3 2 1 bit 0 w 0x00bd pwmdty1 r bit 7 6 5 4 3 2 1 bit 0 w 0x00be pwmdty2 r bit 7 6 5 4 3 2 1 bit 0 w 0x00bf pwmdty3 r bit 7 6 5 4 3 2 1 bit 0 w 0x00c0 pwmdty4 r bit 7 6 5 4 3 2 1 bit 0 w 0x00c1 pwmdty5 r bit 7 6 5 4 3 2 1 bit 0 w 0x00c2 pwmdty6 r bit 7 6 5 4 3 2 1 bit 0 w 0x00c3 pwmdty7 r bit 7 6 5 4 3 2 1 bit 0 w 0x00c4- 0x00c7 reserved r00000000 w 0x00c8?x0cf serial communication interface (sci0) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x00c8 sci0bdh r iren tnp1 tnp0 sbr12 sbr11 sbr10 sbr9 sbr8 w 0x00c8 sci0asr1 r rxedgif 0000 berrv berrif bkdif w 0x00c9 sci0bdl r sbr7 sbr6 sbr5 sbr4 sbr3 sbr2 sbr1 sbr0 w 0x00c9 sci0acr1 r rxedgie 00000 berrie bkdie w 0x00ca sci0cr1 r loops sciswai rsrc m wake ilt pe pt w 0x00ca sci0acr2 r00000 berrm1 berrm0 bkdfe w 0x00cb sci0cr2 r tie tcie rie ilie te re rwu sbk w 0x00a0?x0c7 pulse-width-modulator (pwm)
detailed register address map mc9s12g family reference manual, rev.1.23 1258 freescale semiconductor 0x00cc sci0sr1 r tdre tc rdrf idle or nf fe pf w 0x00cd sci0sr2 r amap 00 txpol rxpol brk13 txdir raf w 0x00ce sci0drh rr8 t8 000000 w 0x00cf sci0drl rr7r6r5r4r3r2r1r0 wt7t6t5t4t3t2t1t0 0x00d0?x0d7 serial communication interface (sci1) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x00d0 sci1bdh r iren tnp1 tnp0 sbr12 sbr11 sbr10 sbr9 sbr8 w 0x00d0 sci1asr1 r rxedgif 0000 berrv berrif bkdif w 0x00d1 sci1bdl r sbr7 sbr6 sbr5 sbr4 sbr3 sbr2 sbr1 sbr0 w 0x00d1 sci1acr1 r rxedgie 00000 berrie bkdie w 0x00d2 sci1cr1 r loops sciswai rsrc m wake ilt pe pt w 0x00d2 sci1acr2 r00000 berrm1 berrm0 bkdfe w 0x00d3 sci1cr2 r tie tcie rie ilie te re rwu sbk w 0x00d4 sci1sr1 r tdre tc rdrf idle or nf fe pf w 0x00d5 sci1sr2 r amap 00 txpol rxpol brk13 txdir raf w 0x00d6 sci1drh rr8 t8 000000 w 0x00d7 sci1drl rr7r6r5r4r3r2r1r0 wt7t6t5t4t3t2t1t0 0x00d8?x0df serial peripheral interface (spi0) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x00d8 spi0cr1 r spie spe sptie mstr cpol cpha ssoe lsbfe w 0x00d9 spi0cr2 r0 xfrw 0 modfen bidiroe 0 spiswai spc0 w 0x00da spi0br r0 sppr2 sppr1 sppr0 0 spr2 spr1 spr0 w 0x00db spi0sr r spif 0 sptef modf 0 0 0 0 w 0x00c8?x0cf serial communication interface (sci0)
detailed register address map mc9s12g family reference manual, rev.1.23 freescale semiconductor 1259 0x00dc spi0drh r r15 r14 r13 r12 r11 r10 r9 r8 w t15 t14 t13 t12 t11 t10 t9 t8 0x00dd spi0drl rr7r6r5r4r3r2r1r0 wt7t6t5t4t3t2t1t0 0x00de- 0x00df reserved r w 0x00e0?x0e7 reserved address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x00e0- 0x00e7 reserved r00000000 w 0x00e8?x0ef serial communication interface (sci2) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x00e8 sci2bdh r iren tnp1 tnp0 sbr12 sbr11 sbr10 sbr9 sbr8 w 0x00e8 sci2asr1 r rxedgif 0000 berrv berrif bkdif w 0x00e9 sci2bdl r sbr7 sbr6 sbr5 sbr4 sbr3 sbr2 sbr1 sbr0 w 0x00e9 sci2acr1 r rxedgie 00000 berrie bkdie w 0x00ea sci2cr1 r loops sciswai rsrc m wake ilt pe pt w 0x00ea sci2acr2 r00000 berrm1 berrm0 bkdfe w 0x00eb sci2cr2 r tie tcie rie ilie te re rwu sbk w 0x00ec sci2sr1 r tdre tc rdrf idle or nf fe pf w 0x00ed sci2sr2 r amap 00 txpol rxpol brk13 txdir raf w 0x00ee sci2drh rr8 t8 000000 w 0x00ef sci2drl rr7r6r5r4r3r2r1r0 wt7t6t5t4t3t2t1t0 0x00f0?x0f7 serial peripheral interface (spi1) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x00f0 spi1cr1 r spie spe sptie mstr cpol cpha ssoe lsbfe w 0x00f1 spi1cr2 r0 xfrw 0 modfen bidiroe 0 spiswai spc0 w 0x00d8?x0df serial peripheral interface (spi0)
detailed register address map mc9s12g family reference manual, rev.1.23 1260 freescale semiconductor 0x00f2 spi1br r0 sppr2 sppr1 sppr0 0 spr2 spr1 spr0 w 0x00f3 spi1sr r spif 0 sptef modf 0 0 0 0 w 0x00f4 spi1drh r r15 r14 r13 r12 r11 r10 r9 r8 w t15 t14 t13 t12 t11 t10 t9 t8 0x00f5 spi1drl rr7r6r5r4r3r2r1r0 wt7t6t5t4t3t2t1t0 0x00f6- 0x00f7 reserved r w 0x00f8?x0ff serial peripheral interface (spi2) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x00f8 spi2cr1 r spie spe sptie mstr cpol cpha ssoe lsbfe w 0x00f9 spi2cr2 r0 xfrw 0 modfen bidiroe 0 spiswai spc0 w 0x00fa spi2br r0 sppr2 sppr1 sppr0 0 spr2 spr1 spr0 w 0x00fb spi2sr r spif 0 sptef modf 0 0 0 0 w 0x00fc spi2drh r r15 r14 r13 r12 r11 r10 r9 r8 w t15 t14 t13 t12 t11 t10 t9 t8 0x00fd spi2drl rr7r6r5r4r3r2r1r0 wt7t6t5t4t3t2t1t0 0x00fe- 0x00ff reserved r w 0x0100?x0113 flash module (ftmrg) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x0100 fclkdiv r fdivld fdivlck fdiv5 fdiv4 fdiv3 fdiv2 fdiv1 fdiv0 w 0x0101 fsec r keyen1 keyen0 rnv5 rnv4 rnv3 rnv2 sec1 sec0 w 0x0102 fccobix r00000 ccobix2 ccobix1 ccobix0 w 0x0103 reserved r00000000 w 0x0104 fcnfg r ccie 00 ignsf 00 fdfd fsfd w 0x0105 fercnfg r000000 dfdie sfdie w 0x0106 fstat r ccif 0 accerr fpviol mgbusy rsvd mgstat1 mgstat0 w 0x00f0?x0f7 serial peripheral interface (spi1)
detailed register address map mc9s12g family reference manual, rev.1.23 freescale semiconductor 1261 0x0107 ferstat r000000 dfdif sfdif w 0x0108 fprot r fpopen rnv6 fphdis fphs1 fphs0 fpldis fpls1 fpls0 w 0x0109 dfprot r dpopen 000 dps3 dps2 dps1 dps0 w 0x010a fccobhi r ccob15 ccob14 ccob13 ccob12 ccob11 ccob10 ccob9 ccob8 w 0x010b fccoblo r ccob7 ccob6 ccob5 ccob4 ccob3 ccob2 ccob1 ccob0 w 0x010c reserved r00000000 w 0x010d reserved r00000000 w 0x010e reserved r00000000 w 0x010f reserved r00000000 w 0x0110 fopt r nv7 nv6 nv5 nv4 nv3 nv2 nv1 nv0 w 0x0111 reserved r00000000 w 0x0112 reserved r00000000 w 0x0113 reserved r00000000 w 0x0114?x11f reserved address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x0114- 0x011f reserved r00000000 w 0x0120 interrupt module (int) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x0120 ivbr r ivb_addr[7:0] w 0x0121?x13f reserved address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x0121- 0x013f reserved r00000000 w 0x0100?x0113 flash module (ftmrg) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
detailed register address map mc9s12g family reference manual, rev.1.23 1262 freescale semiconductor 0x0140?x017f can controller (mscan) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x0140 canctl0 r rxfrm rxact cswai synch time wupe slprq initrq w 0x0141 canctl1 r cane clksrc loopb listen borm wupm slpak initak w 0x0142 canbtr0 r sjw1 sjw0 brp5 brp4 brp3 brp2 brp1 brp0 w 0x0143 canbtr1 r samp tseg22 tseg21 tseg20 tseg13 tseg12 tseg11 tseg10 w 0x0144 canrflg r wupif cscif rstat1 rstat0 tstat1 tstat0 ovrif rxf w 0x0145 canrier r wupie cscie rstate1 rstate0 tstate1 tstate0 ovrie rxfie w 0x0146 cantflg r0 0 0 00 txe2 txe1 txe0 w 0x0147 cantier r00000 txeie2 txeie1 txeie0 w 0x0148 cantarq r00000 abtrq2 abtrq1 abtrq0 w 0x0149 cantaak r00000 abtak2 abtak1 abtak0 w 0x014a cantbsel r00000 tx2 tx1 tx0 w 0x014b canidac r0 0 idam1 idam0 0 idhit2 idhit1 idhit0 w 0x014c reserved r00000000 w 0x014d canmisc r0000000 bohold w 0x014e canrxerr r rxerr7 rxerr6 rxerr5 rxerr4 rxerr3 rxerr2 rxerr1 rxerr0 w 0x014f cantxerr r txerr7 txerr6 txerr5 txerr4 txerr3 txerr2 txerr1 txerr0 w 0x0150- 0x0153 canidar0? r ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 w 0x0154- 0x0157 canidmrx r am7 am6 am5 am4 am3 am2 am1 am0 w 0x0158- 0x015b canidar4? r ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 w 0x015c- 0x015f canidmr4? r am7 am6 am5 am4 am3 am2 am1 am0 w 0x0160- 0x016f canrxfg r see section 18.3.3, ?rogrammers model of message storage w 0x0170- 0x017f cantxfg r see section 18.3.3, ?rogrammers model of message storage w
detailed register address map mc9s12g family reference manual, rev.1.23 freescale semiconductor 1263 0x0180?x023f reserved address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x0180- 0x023f reserved r00000000 w 0x0240?x025f port integration module (pim) map 4 of 6 address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x0240 ptt r ptt7 ptt6 ptt5 ptt4 ptt3 ptt2 ptt1 ptt0 w 0x0241 ptit r ptit7 ptit6 ptit5 ptit4 ptit3 ptit2 ptit1 ptit0 w 0x0242 ddrt r ddrt7 ddrt6 ddrt5 ddrt4 ddrt3 ddrt2 ddrt1 ddrt0 w 0x0243 reserved r00000000 w 0x0244 pert r pert7 pert6 pert5 pert4 pert3 pert2 pert1 pert0 w 0x0245 ppst r ppst7 ppst6 ppst5 ppst4 ppst3 ppst2 ppst1 ppst0 w 0x0246- 0x0247 reserved r00000000 w 0x0248 pts r pts7 pts6 pts5 pts4 pts3 pts2 pts1 pts0 w 0x0249 ptis r ptis7 ptis6 ptis5 ptis4 ptis3 ptis2 ptis1 ptis0 w 0x024a ddrs r ddrs7 ddrs6 ddrs5 ddrs4 ddrs3 ddrs2 ddrs1 ddrs0 w 0x024b reserved r00000000 w 0x024c pers r pers7 pers6 pers5 pers4 pers3 pers2 pers1 pers0 w 0x024d ppss r ppss7 ppss6 ppss5 ppss4 ppss3 ppss2 ppss1 ppss0 w 0x024e woms r woms7 woms6 woms5 woms4 woms3 woms2 woms1 woms0 w 0x024f prr0 r prr0p3 prr0p2 prr0t31 prr0t30 prr0t21 prr0t20 prr0s1 prr0s0 w 0x0250 ptm r0000 ptm3 ptm2 ptm1 ptm0 w 0x0251 ptim r 0 0 0 0 ptim3 ptim2 ptim1 ptim0 w 0x0252 ddrm r0000 ddrm3 ddrm2 ddrm1 ddrm0 w 0x0253 reserved r00000000 w
detailed register address map mc9s12g family reference manual, rev.1.23 1264 freescale semiconductor 0x0254 perm r0000 perm3 perm2 perm1 perm0 w 0x0255 ppsm r0000 ppsm3 ppsm2 ppsm1 ppsm0 w 0x0256 womm r0000 womm3 womm2 womm1 womm0 w 0x0257 pkgcr r apiclks7 0000 pkgcr2 pkgcr1 pkgcr0 w 0x0258 ptp r ptp7 ptp6 ptp5 ptp4 ptp3 ptp2 ptp1 ptp0 w 0x0259 ptip r ptip7 ptip6 ptip5 ptip4 ptip3 ptip2 ptip1 ptip0 w 0x025a ddrp r ddrp7 ddrp6 ddrp5 ddrp4 ddrp3 ddrp2 ddrp1 ddrp0 w 0x025b reserved r00000000 w 0x025c perp r perp7 perp6 perp5 perp4 perp3 perp2 perp1 perp0 w 0x025d ppsp r ppsp7 ppsp6 ppsp5 ppsp4 ppsp3 ppsp2 ppsp1 ppsp0 w 0x025e piep r piep7 piep6 piep5 piep4 piep3 piep2 piep1 piep0 w 0x025f pifp r pifp7 pifp6 pifp5 pifp4 pifp3 pifp2 pifp1 pifp0 w 0x0260?x0261 analog comparator(acmp) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 w 0x0260 acmpc r acie acope acice 0 acmod1 acmod0 0 ace w 0x0261 acmps r acif aco 0 0 0 0 0 0 w 0x0262?x0275 port integration module (pim) map 5 of 6 address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x0262- 0x0267 reserved r00000000 w 0x0267 reserved r reserved reserved 00000 reserved w 0x0268 ptj r ptj7 ptj6 ptj5 ptj4 ptj3 ptj2 ptj1 ptj0 w 0x0269 ptij r ptij7 ptij6 ptij5 ptij4 ptij3 ptij2 ptij1 ptij0 w 0x0240?x025f port integration module (pim) map 4 of 6 address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
detailed register address map mc9s12g family reference manual, rev.1.23 freescale semiconductor 1265 0x026a ddrj r ddrj7 ddrj6 ddrj5 ddrj4 ddrj3 ddrj2 ddrj1 ddrj0 w 0x026b reserved r00000000 w 0x026c perj r perj7 perj6 perj5 perj4 perj3 perj2 perj1 perj0 w 0x026d ppsj r ppsj7 ppsj6 ppsj5 ppsj4 ppsj3 ppsj2 ppsj1 ppsj0 w 0x026e piej r piej7 piej6 piej5 piej4 piej3 piej2 piej1 piej0 w 0x026f pifj r pifj7 pifj6 pifj5 pifj4 pifj3 pifj2 pifj1 pifj0 w 0x0270 pt0ad r pt0ad7 pt0ad6 pt0ad5 pt0ad4 pt0ad3 pt0ad2 pt0ad1 pt0ad0 w 0x0271 pt1ad r pt1ad7 pt1ad6 pt1ad5 pt1ad4 pt1ad3 pt1ad2 pt1ad1 pt1ad0 w 0x0272 pti0ad r pti0ad7 pti0ad6 pti0ad5 pti0ad4 pti0ad3 pti0ad2 pti0ad1 pti0ad0 w 0x0273 pti1ad r pti1ad7 pti1ad6 pti1ad5 pti1ad4 pti1ad3 pti1ad2 pti1ad1 pti1ad0 w 0x0274 ddr0ad r ddr0ad7 ddr0ad6 ddr0ad5 ddr0ad4 ddr0ad3 ddr0ad2 ddr0ad1 ddr0ad0 w 0x0275 ddr1ad r ddr1ad7 ddr1ad6 ddr1ad5 ddr1ad4 ddr1ad3 ddr1ad2 ddr1ad1 ddr1ad0 w 0x0276 reference voltage attenuator (rva) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x0276 rvactl r0000000 rvaon w 0x0277?x027f port integration module (pim) map 6 of 6 address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x0277 prr1 r0000000 prr1an w 0x0278 per0ad r per0ad7 per0ad6 per0ad5 per0ad4 per0ad3 per0ad2 per0ad1 per0ad0 w 0x0279 per1ad r per1ad7 per1ad6 per1ad5 per1ad4 per1ad3 per1ad2 per1ad1 per1ad0 w 0x027a pps0ad r pps0ad7 pps0ad6 pps0ad5 pps0ad4 pps0ad3 pps0ad2 pps0ad1 pps0ad0 w 0x027b pps1ad r pps1ad7 pps1ad6 pps1ad5 pps1ad4 pps1ad3 pps1ad2 pps1ad1 pps1ad0 w 0x0262?x0275 port integration module (pim) map 5 of 6 address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
detailed register address map mc9s12g family reference manual, rev.1.23 1266 freescale semiconductor 0x027c pie0ad r pie0ad7 pie0ad6 pie0ad5 pie0ad4 pie0ad3 pie0ad2 pie0ad1 pie0ad0 w 0x027d pie1ad r pie1ad7 pie1ad6 pie1ad5 pie1ad4 pie1ad3 pie1ad2 pie1ad1 pie1ad0 w 0x027e pif0ad r pif0ad7 pif0ad6 pif0ad5 pif0ad4 pif0ad3 pif0ad2 pif0ad1 pif0ad0 w 0x027f pif1ad r pif1ad7 pif1ad6 pif1ad5 pif1ad4 pif1ad3 pif1ad2 pif1ad1 pif1ad0 w 0x0280?x2ef reserved address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x0280- 0x02ef reserved r00000000 w 0x02f0?x02ff clock and power management (cpmu) map 2 of 2 address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x02f0 reserved r00000000 w 0x02f1 cpmulvctl r00000lvds lvie lvif w 0x02f2 cpmuapictl r apiclk 00 apies apiea apife apie apif w 0x02f3 cpmuaclktr r aclktr5 aclktr4 aclktr3 aclktr2 aclktr1 aclktr0 00 w 0x02f4 cpmuapirh r apir15 apir14 apir13 apir12 apir11 apir10 apir9 apir8 w 0x02f5 cpmuapirl r apir7 apir6 apir5 apir4 apir3 apir2 apir1 apir0 w 0x02f6 reserved r00000000 w 0x02f7 reserved r00000000 w 0x02f8 cpmu irctrimh r tctrim[3:0] 00 irctrim[9:8] w 0x02f9 cpmu irctriml r irctrim[7:0] w 0x02fa cpmuosc r osce reserved oscpins_en reserved w 0x0277?x027f port integration module (pim) map 6 of 6 address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
detailed register address map mc9s12g family reference manual, rev.1.23 freescale semiconductor 1267 0x02fb cpmuprot r0000000 prot w 0x02fc reserved r00000000 w 0x02fd- 0x02ff reserved r00000000 w 0x0300?x03bf reserved address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x0300- 0x03bf reserved r00000000 w 0x03c0?x03c7 digital to analog converter (dac0) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x03c0 dac0ctl r fvr drive 000 mode[2:0] w 0x03c1 reserved r00000000 w 0x03c2 dac0voltage r voltage[7:0] w 0x03c3 reserved r00000000 w 0x03c4 reserved r00000000 w 0x03c5 reserved r00000000 w 0x03c6 reserved r00000000 w 0x03c7 reserved r00000000 w 0x03c8?x03cf digital to analog converter (dac1) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x03c8 dac1ctl r fvr drive 000 mode[2:0] w 0x03c9 reserved r00000000 w 0x03ca dac1voltage r voltage[7:0] w 0x03cb reserved r00000000 w 0x02f0?x02ff clock and power management (cpmu) map 2 of 2
detailed register address map mc9s12g family reference manual, rev.1.23 1268 freescale semiconductor 0x03cc reserved r00000000 w 0x03cd reserved r00000000 w 0x03ce reserved r00000000 w 0x03cf reserved r00000000 w 0x03d0?x03ff reserved address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0x03d0- 0x03ff reserved r00000000 w 0x03c8?x03cf digital to analog converter (dac1)
ordering and shipping information mc9s12g family reference manual, rev.1.23 freescale semiconductor 1269 appendix c ordering and shipping information revision history c.1 ordering information the following ?ure provides an ordering part number example for the devices covered by this data book. there are two options when ordering a device. customers must choose between ordering either the mask-speci? part number or the generic / mask-independent part number. ordering the mask-speci? part number enables the customer to specify which particular mask set they will receive whereas ordering the generic mask set means that fsl will ship the currently preferred mask set (which may change over time). in either case, the marking on the device will always show the generic / mask-independent part number and the mask set number. note the mask identi?r suf? and the tape & reel suf? are always both omitted from the part number which is actually marked on the device. for speci? part numbers to order, please contact your local sales of?e. the below ?ure illustrates the structure of a typical mask-speci? ordering number for the mc9s12g devices version number revision date description of changes rev 0.01 2-jan-2009 initial release rev 0.02 22-nov-2012 added temperature option w rev 0.03 25-jan-2013 updated c.1, ?rdering information (added kgd option) added c.2, ?gd shipping information rev 0.04 1-feb-2013 removed c.2, ?gd shipping information
ordering and shipping information mc9s12g family reference manual, rev.1.23 1270 freescale semiconductor figure c-1. order part number example s w 9 s12 g128 f0 m ll r package option: temperature option: device title controller family c = -40?c to 85?c v = -40?c to 105?c m = -40?c to 125?c tj = 20 tssop lc = 32 lqfp lf = 48 lqfp status / part number type: s or sc = mask set specific part number mc = generic / mask-independent part number p or pc = prototype status (pre qualification) main memory type: 9 or no number = flash mask set identifier suffix: first digit usually references wafer fab second digit usually differentiates mask rev (this suffix is omitted in generic part numbers) tape & reel: r = tape & reel no r = no tape & reel lh = 64 lqfp ll = 100 lqfp ft = 48 qfn w = -40?c to 150?c shipping option: w = kgd (known good die) no w = packaged device
package and die information mc9s12g family reference manual, rev.1.23 freescale semiconductor 1271 appendix d package and die information revision history version number revision date description of changes rev 0.01 2-jan-2009 initial release rev 0.02 25-jan-2013 added d.7, ?gd information rev 0.03 31-jan-2013 updated , ?ondpad coordinates
package and die information mc9s12g family reference manual, rev.1.23 1272 freescale semiconductor d.1 100 lqfp mechanical dimensions
package and die information mc9s12g family reference manual, rev.1.23 freescale semiconductor 1273
package and die information mc9s12g family reference manual, rev.1.23 1274 freescale semiconductor
package and die information mc9s12g family reference manual, rev.1.23 freescale semiconductor 1275 d.2 64 lqfp mechanical dimensions
package and die information mc9s12g family reference manual, rev.1.23 1276 freescale semiconductor
package and die information mc9s12g family reference manual, rev.1.23 freescale semiconductor 1277
package and die information mc9s12g family reference manual, rev.1.23 1278 freescale semiconductor d.3 48 lqfp mechanical dimensions
package and die information mc9s12g family reference manual, rev.1.23 freescale semiconductor 1279
package and die information mc9s12g family reference manual, rev.1.23 1280 freescale semiconductor d.4 48 qfn mechanical dimensions
package and die information mc9s12g family reference manual, rev.1.23 freescale semiconductor 1281
package and die information mc9s12g family reference manual, rev.1.23 1282 freescale semiconductor
package and die information mc9s12g family reference manual, rev.1.23 freescale semiconductor 1283 d.5 32 lqfp mechanical dimensions
package and die information mc9s12g family reference manual, rev.1.23 1284 freescale semiconductor
package and die information mc9s12g family reference manual, rev.1.23 freescale semiconductor 1285
package and die information mc9s12g family reference manual, rev.1.23 1286 freescale semiconductor d.6 20 tssop mechanical dimensions
package and die information mc9s12g family reference manual, rev.1.23 freescale semiconductor 1287
package and die information mc9s12g family reference manual, rev.1.23 1288 freescale semiconductor
package and die information mc9s12g family reference manual, rev.1.23 freescale semiconductor 1289 d.7 kgd information bondpad coordinates table d-1. bondpad coordinates die pad bond post die pad x coordinate die pad y coordinate function 1 1 -1832.06 1347.5 pj[6] 2 2 -1832.06 1223.5 pj[5] 3 3 -1832.06 1116.5 pj[4] 4 4 -1832.06 1009.5 pa[0] 5 5 -1832.06 902.5 pa[1] 6 6 -1832.06 795.5 pa[2] 7 7 -1832.06 688.5 pa[3] 8 8 -1832.06 603.5 reset 9 9 -1832.06 496.5 vddx1 10 10 -1832.06 369 vddr 11 11 -1832.06 241.5 vssx1 12 12 -1832.06 136.5 pe[0] 13 13 -1832.06 22.5 vss1 14 14 -1832.06 -91.5 pe[1] 15 15 -1832.06 -201.5 test 16 16 -1832.06 -311.5 pa[4] 17 17 -1832.06 -396.5 pa[5] 18 18 -1832.06 -483.5 pa[6] 19 19 -1832.06 -578.5 pa[7] 20 20 -1832.06 -683.5 pj[0] 21 21 -1832.06 -797.5 pj[1] 22 22 -1832.06 -921.5 pj[2] 23 23 -1832.06 -1054.5 pj[3] 24 24 -1832.06 -1196.5 bkgd 25 25 -1832.06 -1347.5 pb[0] 26 26 -1707.5 -1472.06 pb[1] 27 27 -1506.5 -1472.06 pb[2]
package and die information mc9s12g family reference manual, rev.1.23 1290 freescale semiconductor 28 28 -1315.5 -1472.06 pb[3] 29 29 -1134.5 -1472.06 pp[0] 30 30 -964.5 -1472.06 pp[1] 31 31 -794.5 -1472.06 pp[2] 32 32 -660.5 -1472.06 pp[3] 33 33 -526.5 -1472.06 pp[4] 34 34 -404.5 -1472.06 pp[5] 35 35 -292.5 -1472.06 pp[6] 36 36 -190.5 -1472.06 pp[7] 37 37 -105.5 -1472.06 vddx3 38 38 -0.5 -1472.06 vssx3 39 39 93.5 -1472.06 pt[7] 40 40 189.5 -1472.06 pt[6] 41 41 291.5 -1472.06 pt[5] 42 42 403.5 -1472.06 pt[4] 43 43 525.5 -1472.06 pt[3] 44 44 659.5 -1472.06 pt[2] 45 45 805.5 -1472.06 pt[1] 46 46 964.5 -1472.06 pt[0] 47 47 1120.5 -1472.06 pb[4] 48 48 1242.5 -1472.06 pb[5] 49 49 1412.5 -1472.06 pb[6] 50 50 1582.5 -1472.06 pb[7] 51 51 -1832.06 -1347.5 pc[0] 52 52 -1832.06 -1139.5 pc[1] 53 53 -1832.06 -1022.5 pc[2] 54 54 -1832.06 -905.5 pc[3] 55 55 -1832.06 -788.5 pad[0] 56 56 -1832.06 -681.5 pad[8] 57 57 -1832.06 -574.5 pad[1] table d-1. bondpad coordinates die pad bond post die pad x coordinate die pad y coordinate function
package and die information mc9s12g family reference manual, rev.1.23 freescale semiconductor 1291 58 58 -1832.06 -467.5 pad[9] 59 59 -1832.06 -360.5 pad[2] 60 60 -1832.06 -253.5 pad[10] 61 61 -1832.06 -148.5 pad[3] 62 62 -1832.06 -41.5 pad[11] 63 63 -1832.06 65.5 pad[4] 64 64 -1832.06 172.5 pad[12] 65 65 -1832.06 279.5 pad[5] 66 66 -1832.06 386.5 pad[13] 67 67 -1832.06 493.5 pad[6] 68 68 -1832.06 598.5 pad[14] 69 69 -1832.06 705.5 pad[7] 70 70 -1832.06 812.5 pad[15] 71 71 -1832.06 919.5 pc[4] 72 72 -1832.06 1026.5 pc[5] 73 73 -1832.06 1133.5 pc[6] 74 74 -1832.06 1240.5 pc[7] 75 75 -1832.06 1347.5 vrh 76 76 1707.5 -1472.06 vdda 77 77 1598.5 -1472.06 vrl 78 77 1477.5 -1472.06 vssa 79 78 1237.5 -1472.06 pd[0] 80 79 1117.5 -1472.06 pd[1] 81 80 947.5 -1472.06 pd[2] 82 81 777.5 -1472.06 pd[3] 83 82 652.5 -1472.06 ps[0] 84 83 527.5 -1472.06 ps[1] 85 84 422.5 -1472.06 ps[2] 86 85 327.5 -1472.06 ps[3] 87 86 242.5 -1472.06 ps[4] table d-1. bondpad coordinates die pad bond post die pad x coordinate die pad y coordinate function
package and die information mc9s12g family reference manual, rev.1.23 1292 freescale semiconductor 88 87 128.5 -1472.06 ps[5] 89 88 14.5 -1472.06 ps[6] 90 89 -99.5 -1472.06 ps[7] 91 90 -213.5 -1472.06 vssx2 92 91 -318.5 -1472.06 vddx2 93 92 -428.5 -1472.06 pm[0] 94 93 -548.5 -1472.06 pm[1] 95 94 -688.5 -1472.06 pd[4] 96 95 -828.5 -1472.06 pd[5] 97 96 -998.5 -1472.06 pd[6] 98 97 -1168.5 -1472.06 pd[7] 99 98 -1338.5 -1472.06 pm[2] 100 99 -1518.5 -1472.06 pm[3] 101 100 -1707.5 -1472.06 pj[7] table d-1. bondpad coordinates die pad bond post die pad x coordinate die pad y coordinate function

how to reach us: usa/europe/locations not listed: freescale semiconductor literature distribution p.o. box 5405, denver, colorado 80217 1-800-521-6274 or 480-768-2130 japan: freescale semiconductor japan ltd. sps, technical information center 3-20-1, minami-azabu minato-ku tokyo 106-8573, japan 81-3-3440-3569 asia/paci?: freescale semiconductor h.k. ltd. 2 dai king street tai po industrial estate tai po, n.t. hong kong 852-26668334 learn more: for more information about freescale semiconductor products, please visit http://www.freescale.com information in this document is provided solely to enable system and software implementers to use freescale semiconductor products. there are no express or implied copyright licenses granted hereunder to design or fabricate any integrated circuits or integrated circuits based on the information in this document. freescale semiconductor reserves the right to make changes without further notice to any products herein. freescale semiconductor makes no warranty, representation or guarantee regarding the suitability of its products for any particular purpose, nor does freescale semiconductor assume any liability arising out of the application or use of any product or circuit, and speci?ally disclaims any and all liability, including without limitation consequential or incidental damages. typical parameters which may be provided in freescale semiconductor data sheets and/or speci?ations can and do vary in different applications and actual performance may vary over time. all operating parameters, including ?ypicals must be validated for each customer application by customers technical experts. freescale semiconductor does not convey any license under its patent rights nor the rights of others. freescale semiconductor products are not designed, intended, or authorized for use as components in systems intended for surgical implant into the body, or other applications intended to support or sustain life, or for any other application in which the failure of the freescale semiconductor product could create a situation where personal injury or death may occur. should buyer purchase or use freescale semiconductor products for any such unintended or unauthorized application, buyer shall indemnify and hold freescale semiconductor and its of?ers, employees, subsidiaries, af?iates, and distributors harmless against all claims, costs, damages, and expenses, and reasonable attorney fees arising out of, directly or indirectly, any claim of personal injury or death associated with such unintended or unauthorized use, even if such claim alleges that freescale semiconductor was negligent regarding the design or manufacture of the part. freescale and the freescale logo are trademarks of freescale semiconductor, inc. all other product or service names are the property of their respective owners. ?freescale semiconductor, inc. 2006


▲Up To Search▲   

 
Price & Availability of S9S12G128F0MLH

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X